You don't need to unlock your phone to show this ID though...
However if during that time the officer sees material that constitutes probable cause for a search, they can seize the phone without your ability to withdraw consent.
IANAL
The police officer may also have taken your phone back to their car to use the ID details to write up the ticket so you can't easily ask form the phone back at that point.
It is way easier for law enforcement to get into phones after first unlock than it is from a powered down phone.
“ Users do not need to unlock, show, or hand over their device to present their ID.”
https://www.apple.com/newsroom/2021/09/apple-announces-first...