If so how would this have worked?
They did, but only for two rather short periods.
Philip II and Mary were married in England on 25 July 1554. He stayed there for some time, but was mostly based out of the Low Countries together with his father Charles V, who was in the process of abdicating his many titles. At this point, only the Duchy of Milan had been abdicated to Philip, so he was not yet King of Spain. An even longer exposition would say that there was not yet "Spain" as we know it today, rather the crowns of Castille, Aragon, and Navarra.
The Low Countries rulerships were abdicated in October 1555 in a famous speech, and finally Spain's kingships were abdicated in 1556. So technically, Philip was not yet King of Spain when they were married. He was King of both Spain and England (among many, many other things) only in 1556 until 1558 when Mary died.
Philip II visited England twice:
July 1554 to August 1555 for their first meeting and marriage a few days following.
March to July 1557 following his ascension to king of Spain's dominions.
By contrast, Mary stayed in England through the entire period. There were many reasons for this, including that she had to keep her (Protestant) adversaries in check.
The articles of the marriage states that Philip was to have the title King of England together with Mary, only as long as Mary was to live, but that his co-rule would be limited. Most importantly, he could not appoint champions to any office.
Mary died in 1558. Philip returned to Spain from the Low Countries in 1559, never to be able to return.
References: