South Africa's embattled President Jacob Zuma has resigned after intense pressure from his own party.