The instructions apply to all iOS devices.
Tap your name at the top of theSettingsscreen.
Scroll to the bottom of the screen.

input your Apple Account when prompted and then tapTurn Off.
This turns off Find My iPhone, which you have to do before you turn off iCloud.
Next, choose what data you want to keep a copy of on this iPhone.
Move the slider to on/green forCalendars,Contacts,Keychain,Safari, and/orStocks.
After this, tapSign Outin the top right corner.
TapSign Outone more time and you’ll finally be signed out of iCloud.
Remember, signing out of iCloud also signs you out of Find My iPhone, FaceTime, and iMessage.
Find My iPhone requires iCloud be turned on.
In the pop-up, tapDelete from My iPhone.
Choose the data you want to keep a copy of on your iPhone.
Enter yourApple Accountwhen prompted.
TapTurn Offto disable iCloud.
But iCloud does a lot more than that, too.
They are, but you still might want to turn them off.
You might also want to prevent data from syncing from your iPhone to other devices.
On iOS 10.2 or lower, skip this step.
Move sliders there to off/white to disable them as well.
choose the conversation holding the messages you want to recover, tapRecover, and then tapRecover MessageorRecover Messages.
On your iPhone, tap theFilesapp to access any data you’ve synced to iCloud.
Toaccess iCloud photos from your iPhone, initiate the Photos app and tapLibrary.