在UIStatusBar中(或上)写一些文字 [英] Write some text in (or on) UIStatusBar

查看:116
本文介绍了在UIStatusBar中(或上)写一些文字的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

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

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.

谢谢!

推荐答案

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

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];

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

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.

这篇关于在UIStatusBar中(或上)写一些文字的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆