Italy's Prime Minister Matteo Renzi announced his resignation when it became clear he was losing a referendum on constitutional reform.