iOS:背景透明的模态视图? [英] iOS : ModalView with background transparent?
问题描述
我想在 viewController 上显示一个模态视图.(它有一个导航控制器).
I want to show a modalview on a viewController. (which has a naviguation controller).
在我看来,我有文本和一个显示模态视图的按钮.
On my view i have text, and a button to show the modalview.
我创建了一个 .xib,其中包含我的模态视图(它是一个带有图像和标签的视图).
I created a .xib which contained my modalview (it's a view with an image and a label).
当我展示它时:
ShareController *controller = [[ShareController alloc] initWithNibName:@"ShareController" bundle: nil];
controller.view.backgroundColor = [UIColor clearColor];
controller.modalPresentationStyle = UIModalPresentationFormSheet;
controller.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
[self presentViewController:controller animated:YES completion:nil];
我有我的模态视图,但是,背景变黑了.. 我想总是看到我视图上的文本.(我试图设置 alpha 等.但没有运行:'()
i have my modalview, BUT, the background become black.. and i want to see always the text on my view. (i tried to set alpha, etc..; but NOTHING runs :'( )
有人帮我吗?
谢谢,
推荐答案
你可以查看iOS7的例子(见我的comm)或者你可以简单地试试这个:
you can check the iOS7 example (see my comm) or you can simple try this:
从你的展示"方法中删除这一行
remove this line from your "presenting" method
controller.view.backgroundColor = [UIColor clearColor];
现在,在 ShareController
的 viewDidLoad 中添加:
now, in viewDidLoad of the ShareController
add:
self.view.backgroundColor = [UIColor clearColor];
self.modalPresentationStyle = UIModalPresentationCurrentContext;
self.modalPresentationStyle = UIModalPresentationFormSheet;
PS
如果你有一个 navigationController... 使用
if you have a navigationController... use
[self.navigationController presentViewController:controller animated:YES completion:nil];
这篇关于iOS:背景透明的模态视图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!