废话不多说,上地址:https://github.com/Co2333/StatusBarFucker
这是一个使用lldb image lookup(找方法)和ivarDescription(找地址)深度查找揪出来的私有方法,苹果大概率不会让你上架,但是有先例子:学习强国。
接下来,咱们work through一遍。
1 - 连接到SpringBoard,咱们先开模拟器,然后 lldb attach SpringBoard
2 - 然后用指令po来获取当前的StatusBar
UIStatusBar_Modern: 0x7fac3d111250
3 - 反复使用ivarDescription来获取我们需要的指针。
3.1 - po [[[UIApplication sharedApplication] statusBar] _ivarDescription]
3.2 - po [0x7fac3a413de0 _ivarDescription] 其中,0x7fac3a413de0,为statusbar的地址,已在上图标出。
_items (NSMutableDictionary*): <__NSDictionaryM: 0x60000117aea0>
3.3 - po 0x60000117aea0 寻找我们要的TimeItem。
"<_UIStatusBarIdentifier: 0x600001103620: object=_UIStatusBarTimeItem>" = "<_UIStatusBarTimeItem: 0x600003200eb0: identifier=<_UIStatusBarIdentifier: 0x600001103620: object=_UIStatusBarTimeItem>>";
3.4 - po [0x600003200eb0 _ivarDescription] 继续打印我们的Item寻找那个ShortTimeView。同时image lookup给了我们他的名字:_UIStatusBarStringView
_shortTimeView (_UIStatusBarStringView*): <_UIStatusBarStringView: 0x7fac3d337280>
3.5 最后,把他当UILabelView拿来用就行了
(lldb) po [0x7fac3d337280 setText:@"@Lakr233"]
4 效果图:
Twitter:@Lakr233
最后,感谢一下 https://www.raywenderlich.com/ 的书,真香。