iOS开发之状态栏UIStatusBar图标操作

时间:2023-03-08 20:52:03
NSArray *subIcons = [[[[UIApplication sharedApplication] valueForKeyPath:@"statusBar"] valueForKeyPath:@"foregroundView"] subviews];
Printing description of subIcons:
<__NSArrayM 0x7ff61141b640>(
<UIStatusBarServiceItemView: 0x7ff61171ad10; frame = ( ; ); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x7ff611712480>> [Item = <UIStatusBarItem: 0x7ff61170fa90> [UIStatusBarServiceItemView (Left)]],
<UIStatusBarDataNetworkItemView: 0x7ff61141b010; frame = ( ; ); autoresize = RM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x7ff611419c60>> [Item = <UIStatusBarItem: 0x7ff611419670> [UIStatusBarDataNetworkItemView (Left)]],
<UIStatusBarBatteryItemView: 0x7ff61141bad0; frame = ( ; ); autoresize = LM+BM; userInteractionEnabled = NO; layer = <CALayer: 0x7ff61141a720>> [Item = <UIStatusBarItem: 0x7ff61141a880> [UIStatusBarBatteryItemView (Right)]],
<UIStatusBarTimeItemView: 0x7ff6114212c0; frame = ( ; ); userInteractionEnabled = NO; layer = <CALayer: 0x7ff6114216c0>> [Item = <UIStatusBarItem: 0x7ff611702c90> [UIStatusBarTimeItemView (Center)]]
)
 for (id icon in subIcons) {
/......
}