iPad上不规则形状的模态视图 [英] Irregularly shaped Modal View on iPad

查看:201
本文介绍了iPad上不规则形状的模态视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以使用 presentModalViewController 显示不规则形状的模态视图?模态部分覆盖屏幕(演示文稿样式设置为 UIModalPresentationFormSheet

Is it possible to display an irregularly shaped Modal view using presentModalViewController? The modal is covering the screen partially (presentation style is set to UIModalPresentationFormSheet)

我尝试简单地设置superview clipsToBounds 为NO,它不起作用。我似乎也无法摆脱圆角。

I tried simply setting the superview clipsToBounds to NO, it didn't work. I can't seem to get rid of the rounded corner as well.

PS:我试图避免创建自定义视图并手动执行此操作。

PS: I am trying to avoid having to create a custom view and do this manually.

PPS:我从文档中注意到我们现在应该在iOS 5中使用 presentViewController 它没有完成虽然有任何不同。

PPS: I noticed from the docs that we are supposed to use presentViewController now in iOS 5. It didn't accomplish anything different though.

推荐答案

我有点工作了。这有点像黑客,但它确实有效。

I sort of got it working. It's a bit of a hack, but it works.

代码(这是产生模态的控制器内部):

The code (this is inside the controller who spawn the modal):

// Present the modal
[self presentViewController:modalVC animated:YES completion:NULL];

// Let content overflow and shrink superview to a small dimension
modalVC.view.clipsToBounds = NO;
modalVC.view.superview.bounds = CGRectMake(modalVC.view.superview.bounds.origin.x, modalVC.view.superview.bounds.origin.y, 100, 100);

现在只需让模态的视图比superview更大,你就可以对形状发疯了。

Now just make the modal's views bigger than the superview and you can go crazy with the shape.

请注意,触摸只会在超级视图区域注册。

Note that touches will only register on the superview area.

这篇关于iPad上不规则形状的模态视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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