Try holding down the Sleep/Wake and Home buttons at the same time for at least ten seconds, until the Apple logo appears and then allow the device to reboot.
For an iPhone 7 or 7+ try holding down the Sleep/Wake button and the Volume Down button at the same time for at least ten seconds until the Apple logo appears and then allow the phone to restart.
If a restart does not help try a System Restore. First backup your device using iTunes. Also import your photos to your computer and copy all important data. Try restoring as New first and testing it. If it works then try restoring the backup and test it again. The backup could be corrupted and if so you would have to restore as new again. Here are the steps for a Restore: