在 UIStatusBar 中(或上面)写入一些文本

发布于 2024-10-05 06:55:40 字数 115 浏览 0 评论 0原文

我知道,这是一个奇怪的问题^^,

我想知道是否有办法在 UIStatusBar 中(或上面)写入一些文本。特别是,当用户按下 UIButton 时,我想在状态栏上写入一些文本。

谢谢!

I know, it's a strange question ^^,

I would like to know if there is a way to write some text in (or on) the UIStatusBar. In particular I want to write some text on the Status Bar when the user press a UIButton.

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

夏尔 2024-10-12 06:55:40

我不确定您是否可以直接在状态栏中绘制,但您应该能够在自定义视图中在状态栏上绘制。您可以 获取状态栏的框架使用:

CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];

您可以获取应用程序的主窗口(大概是状态栏的超级视图):

UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];

您应该能够将自定义视图直接添加到键中状态栏框架中的窗口。有关似乎“修改”状态栏的应用程序示例,请查看 Reeder

I'm not sure if you can draw directly into the status bar, but you should be able to draw on top of it in a custom view. You can get the status bar's frame using:

CGRect statusBarFrame = [[UIApplication sharedApplication] statusBarFrame];

And you can get the application's main window (presumably the status bar's superview) using:

UIWindow *mainWindow = [[UIApplication sharedApplication] keyWindow];

You should be able to add your custom view directly to the key window in the status bar's frame. For an example of an app that appears to "modify" the status bar, take a look at Reeder.

夜血缘 2024-10-12 06:55:40

不,状态栏是系统控制的元素。第三方应用程序无法修改其内容。

No, the status bar is a system-controlled element. It's content cannot be modified by a third-party application.

氛圍 2024-10-12 06:55:40

MTStatusBarOverlay 就是您想要的:

https://github.com/myell0w/MTStatusBarOverlay

绝对更容易使用!

MTStatusBarOverlay is what you want :

https://github.com/myell0w/MTStatusBarOverlay

Definitely the easier to use !

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文