Why does Apple's mobile phone automatically dim when the health code exits?

Because the automatic brightness level is turned on.

The automatic brightness level of Apple's mobile phone means that the light sensor on the mobile phone monitors the brightness of the external environment, and then achieves the best viewing effect according to the brightness level of the mobile phone screen.

Settings, general, auxiliary functions, display adjustment, just turn off the automatic brightness level.