This TSR article is really helpful, they have them for dozens of countries so you should definitely look into those!
https://www.thestudentroom.co.uk/university/international/study-in-spainBasically, studying at a public university would be fairly cheap, up to £1000 per year according to the article (of course you would have to find accommodation which would add quite a bit to that cost), or private universities can be anywhere from £4000 to £18,000. Not sure if this article was written pre or post Brexit though, so you might want to look into how Brexit would change these fees.
It also says: "If you're enrolled in a Spanish university, you are able to apply for either a general grant or a mobility grant - which is offered by the Ministry for Education. There may also be grants or other financial support available for international students from your own country." You should look into these. I found this website listing some grants (
https://www.gooverseas.com/blog/scholarships-study-abroad-spain) although it does seem like most of them are for post-grad students. You should continue doing research on this and try speaking to students who already study in Spain.
I also found a Reddit post discussing study loans from the Spanish government (
https://www.reddit.com/r/spain/comments/48hj0t/can_anyone_explain_the_spanish_student_loan_system/). Unfortunately, they seem to say that student loans as we have them in the UK are practically non-existent because university is cheap and most people live at home.
So basically, it would be pretty difficult, but not impossible. I'd recommend looking into these grants to see if any are available. If not, I could recommend that you do an au pair year in Spain, perfect your language skills and work to save money. Then you could apply to university there the following year and use these savings to fund the beginning of your studies and work whilst studying to keep funding it. This would take a lot of hard work but wouldn't be impossible. Alternatively, and I think this is a much easier option, you could study at a UK university and do a study abroad, and then study your Masters in Spain (using one of the many scholarships in the link above).