如何在 iPhone 上的顶部导航状态栏下方显示 UIActionSheet

发布于 2024-08-18 01:51:21 字数 491 浏览 6 评论 0原文

我想显示一个从顶部状态栏正下方滑动的操作表。

当我使用导航栏作为要显示的视图时,工作表仍显示在屏幕底部。我怎样才能显示它从顶部开始呢?

我调用以下代码的类是“UIViewController”,

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Hello" delegate:nil 
          cancelButtonTitle:nil 
          destructiveButtonTitle:nil 
          otherButtonTitles:nil];

UINavigationBar *navBar = self.navigationController.navigationBar;

[sheet showInView:navBar];

我见过一些应用程序从状态栏所在的位置显示某种滑出抽屉。(例如:Twitterrific)这是如何完成的?

I would like to display an action sheet sliding from just below the very top status bar.

When I use the navigationBar as the view to show in, the sheet is still displayed at the bottom of the screen. How can I show it originating from the top instead?

The class I'm calling the following code from is a 'UIViewController'

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle:@"Hello" delegate:nil 
          cancelButtonTitle:nil 
          destructiveButtonTitle:nil 
          otherButtonTitles:nil];

UINavigationBar *navBar = self.navigationController.navigationBar;

[sheet showInView:navBar];

I've seen some apps show a sliding out drawer of some sort from where the status bar is.(eg: Twitterrific) How is this done?

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

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

发布评论

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

评论(2

夜吻♂芭芘 2024-08-25 01:51:21

苹果表示,他们只是希望所有操作表都能以相同的方式工作并从相同的方向滑入。因此,没有广告上的方法可以轻松地操纵它们的动画等。

Apple has stated that they simply would like all action sheets to work the same way and slide in from the same direction. Hence there is no advertised way to easily manipulate their animations and such.

七堇年 2024-08-25 01:51:21

当然有可能。确实不容易,但确实如此。这样做:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle...];
sheet.transform = CGAffineTransformmakeRotation(M_PI);
[sheet showInView:view];

它所呈现的视图(这里称为视图)也应该被转换。还可以:

view.transform = CGAffineTransformMakeRotation(M_PI);

使用例如一个空视图,它只负责呈现此 ActionSheet。

我希望这是可以理解的。^^

Sandro Meier

Sure it is possible. Not really easy but it is. Do it like this:

UIActionSheet *sheet = [[UIActionSheet alloc] initWithTitle...];
sheet.transform = CGAffineTransformmakeRotation(M_PI);
[sheet showInView:view];

The view in which it is presented (here called view) should also be transformed. Do also:

view.transform = CGAffineTransformMakeRotation(M_PI);

Use for example an empty view, which just has the job to present this ActionSheet.

I hope it was understanable.^^

Sandro Meier

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