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)")
            }
        }
    }
}
相关推荐
传奇开心果编程1 小时前
【SwiftUI提高练中学】第9课 安全与隐私
swiftui·移动开发·swift·编程语言理论·开发范式·编程框架·声明式ui
Ada's2 小时前
【计算机基础系列】003:Python数据结构
开发语言·数据结构·python
CocoaKier3 小时前
苹果商店详情顶部头图已面向所有开发者开放!
ios·apple
茶底世界之下3 小时前
同一张街拍,两种表达:用 Awaking 试一次高对比黑白
ios
2601_962885723 小时前
如何用 Python 计算 TRIX 三重指数平滑均线指标?
开发语言·python
还卿一钵无情泪3 小时前
Unsloth 微调 构建自己的大模型 没有GPU也能微调
linux·开发语言·人工智能·python·大模型·nlp·unsloth
倔强的石头1065 小时前
应用账号最小权限实践:读写账号、报表账号、运维账号分层
java·运维·开发语言
传人once5 小时前
页面中心圆圈放大效果如何写
开发语言·javascript·ecmascript
NeilYuen5 小时前
【C++】STL源码仿写(二):vector
开发语言·c++
调试人生的显微镜5 小时前
iOS开发入门:Interface Builder、基础控件及UITextField详解
后端·ios