You mention a "UK Company" in one sentence, then "self-employed" in the next. Which one are you actually thinking of? They are totally different. If a UK limited company, you would be an employee on a salary - regardless of whether you control/own it. Also, there are rules as to how many non-resident directors a company may have. There are ways around that (nominee directors, for example), but you start to tun up the overheads at that point, and are getting into some potentially tricky and complex areas of company law. The taxation issues are also potentially complex. Yes, there are double taxation treaty provisions, but you really should get expert advice on this from someone who specialises in the area.
I am not quite sure why you would want to do this? By the time you have added up the costs of running the company, filing all the required returns, preparing and filing the accounts, possibly paying for nominee directors and such, plus private health cover in spain, I can see it costing you considerably more than simply working as an 'autonomo' here and qualifying for free health care and other benefits.