If you do not wish to become a resident, you can stay in Spain for 183 days per year (6 months). You will be considered a resident if you spend an extra day (184 days or more) in the country, so you will have to pay resident taxes there.