Thanks to a helpful comment from @Allan, I've noticed that the app I was proposing could be actually a malware. This is why I have deleted this part of the answer. If you want to see how the previous answer looked like, have a look at revision 2.
You can also do this with a thermal camera but I'll describe how to do it with an...
This method is very easy to use compared to the thermal camera, it's also very accurate. With this tool, you can measure the temperature at different spots on your iPhone such as ones that heat up most (battery, screen, CPU and camera sensors).
First, turn on both your infrared thermometer and you iPhone. Then, point the thermometer to the wanted spots and slowly move around the phone to measure temperature as desired places. Don't forget to cover the whole parts you want to measure to get the overall temperature.

If you're worried about your iPhone overheating, see If your iPhone or iPad gets too hot or too cold for what to do.