Hi,
You will need to review the guidance on statutory residence and take the tests to determine your tax residence position:
RDR3 Statutory Residence Test
You will also need to review article 20 on other income and possibly article 7, if you have premises, to determine who and how your self employment income will be taxed. The treaty is reciprocal, so you can interpose UK and Spain as the 'contracting state' and 'other state', to see the position from both sides.
2014 UK-Spain Double Taxation Convention
Thank you.