swift 监听状态栏frame变化

针对状态栏高度做一些操作

swift 复制代码
import UIKit

class ViewController: UIViewController {

    private var statusBarFrameObservation: NSKeyValueObservation?

    override func viewDidLoad() {
        super.viewDidLoad()
        
        if let statusBarManager = UIApplication.shared.windows.first?.windowScene?.statusBarManager {
            statusBarFrameObservation = statusBarManager.observe(\.statusBarFrame, options: [.new, .old]) { _, change in
                // 处理状态栏变化
                print("Status bar frame changed from \(change.oldValue) to \(change.newValue)")
            }
        }
    }
}
相关推荐
༄沐࿆风࿆࿆5 小时前
JavaScript函数完全指南:从基础语法到闭包原理与应用实战
开发语言·javascript
KobeSacre6 小时前
DelayQueue 源码
java·开发语言
han_hanker6 小时前
重新认识枚举enum
开发语言
鹏易灵6 小时前
C++——8.移动语义初探(移动构造、移动赋值)
开发语言·c++·php
2601_962341307 小时前
计算机毕业设计之jsp考研在线复习平台
java·大数据·开发语言·hadoop·python·考研·课程设计
凯瑟琳.奥古斯特7 小时前
力扣1008:前序重建BST
开发语言·c++·算法·leetcode·职场和发展
2zcode7 小时前
项目文档:基于MATLAB图像处理的饮料瓶灌装液位检测系统设计与实现
开发语言·图像处理·matlab
月疯7 小时前
np.where()[0]的用法
开发语言·python·numpy
z落落7 小时前
C#五大加密算法(AES、DES、MD5、RSA、SHA)
开发语言·c#
namexingyun8 小时前
Scaling Law bug实战启示:从“虚胖“到“精瘦“的算力效率革命
开发语言·网络·人工智能·bug·ai编程