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)")
            }
        }
    }
}
相关推荐
柒.梧.10 分钟前
Java构造器精讲:从基础特征到权限修饰符
开发语言·python
PingdiGuo_guo26 分钟前
C++指针(一)
开发语言·c++
模型时代1 小时前
Arista暗示正在开发AI网络管理遥测工具
开发语言·人工智能·php
张3蜂1 小时前
Python变量与命名规范:从入门到精通
开发语言·python
电商API_180079052471 小时前
京东商品评论API接口封装的心路历程
服务器·开发语言·爬虫·数据分析·php
扶尔魔ocy1 小时前
【转载】QT使用linuxdeployqt打包
开发语言·qt
好家伙VCC2 小时前
# 发散创新:基于Python的TTS语音合成实战与优化策略 在人工智能加速落地的今天,**文本转
java·开发语言·人工智能·python
等D春C夏X2 小时前
最终版C++11/14/17学习大纲(精准核对42条条款)
java·开发语言