A couple of ways!
The basic idea is that iphone cameras vastly outpace webcams (true!) and people should leverage them.
For iOS, there are at least two different apps. I’m currently using epoccam (from corsair/elgato, it’s like $8). There’a another one, at about the same price. Launch app, and it connects to some macOS software.
Apple also has an announced feature for this, that should land in the next OS release.
I imagine there’s similar for non-Apple ecosystems, but I don’t know the details