Parking is prohibited in areas with yellow lines. Within blue lines you need to buy a ticket, but depending on the district these spaces are sometimes free, such as during the night. Green lines are for permit holding residents only, so you can’t park in those.
There are public car parking facilities spread throughout the city. You will also see electronic signs for them as you drive around that tell you how many spaces are available. Search here for car parks in Barcelona. Enter the city name or the exact address where you're searching for a car park.