iPhones focus, like virtually every other AF camera. They use a method called phase detection AF. The camera analyzes light hitting the lens from different points to determine if the image is in focus; essentially, it compares the light rays from two points on opposite sides of the lens, and when they overlap, the image is considered sharp. It works as follows,
(1) An autofocus processor (AFP) makes a small change in the focusing distance.
(2) AFP reads the AF sensor to assess whether, and by how much, focus has improved.
(3) Using the information from (2), the AFP sets the lens to a new focusing distance.
(4) The AFP may repeat steps 2-3 until satisfactory focus has been achieved.
This entire process is usually completed within a fraction of a second. For difficult subjects, the camera may fail to achieve satisfactory focus and will give up on repeating the above sequence, resulting in failed autofocus. This is the dreaded "focus hunting" scenario where the camera focuses back and forth repeatedly without achieving focus lock. This does not, however, mean that focus is not possible for the chosen subject. Whether and why autofocus may fail is primarily determined by 3 factors.
- Light – brighter the light, faster and more accurate focus
- Contrast – the higher the contrast at focus point, faster and more accurate focus
- Motion – the less motion of camera and/or subject, faster and more accurate focus
Extremely accurate focus can be obtained by combining all three factors, shoot in bright conditions, stop all motion (focus point is consistent), and if high contrast exists at consist and bright focus point, focus is near instant.