I have a two year UK visa with multi entries, for 180 days. How are these days calculated? Is traveling to France or Spain taken as leaving the UK? Can I then enter the UK again or must I return to my home country (South Africa) before returning to UK to start another 180 days?
I see you have two very closely related questions. The first being what counts as exiting the UK, the second being, how often can you enter the UK with a multiple entry visa?
The answer to the first question is quite simple. You have to leave the country through an immigration check. This is as simple as crossing the Channel by boat. You can also fly to any other country. It does not have to be your home country.
The second question is slightly more complicated. For more information about this, see Doc's detailed answer over here: https://travel.stackexchange.com/a/18947/36405. A quick summary: A visa is issued for a specific purpose, like vacation, visiting family/friends or business. It is not for living in the country. So-called visa-runs are certainly possible (going to France and immediately going back), it is against the purpose of the visa. Use your visa for it's intended purpose.
I have a two year UK visa with multi entries, for 180 days. How are these days calculated? Is traveling to France or Spain taken as leaving the UK?
Can I then enter the UK again or must I return to my home country (South Africa) before returning to UK to start another 180 days?
Visitor visas are not for living in a country.
Some countries have hard and fast rules on total length of multiple visits (for example the famous 90/180 rule in schengen). Others like the UK and the USA give the border gaurds more discretion. It's up to you to convince the border gaurd that you are a genuine visitor and not someone lving in the country while claming to be a visitor. The more your travel profile looks like someone living in the UK (i.e. long periods in, short periods out) the harder that will get.