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)")
            }
        }
    }
}
相关推荐
fl1768311 分钟前
基于C#WPF实现的内存加速球清理类似360加速球内存清理
开发语言·c#·wpf
weixin_440730505 分钟前
python+request实现接口-小结
开发语言·python
ZJU_统一阿萨姆29 分钟前
【算子开发】扫描(Scan)与前缀和
开发语言·arm开发·架构·系统架构·硬件架构
-凌凌漆-30 分钟前
【C语言】结构体typedef struct与struct的区别
c语言·开发语言
for_ever_love__1 小时前
PySpark学习: 数据输出
开发语言·python·学习·spark
言乐61 小时前
Python实现自动拉人脚本示例
开发语言·windows·python·django·pygame
啊啊啊啊啊!!!!1 小时前
【c++】二叉搜索树
开发语言·c++
我血条子呢1 小时前
iOS 软键盘遮挡底部输入框解决报告
ios
归去来 兮2 小时前
Python爬虫爬取数据案例
开发语言·爬虫·python
ShineWinsu2 小时前
对于 C++:C++20中Concept(概念) 与 Coroutine(协程)的解析
linux·开发语言·网络·c++·c++20·epoll