[英]How to keep background transparent when presentViewController in iPhone?
I want to keep background transparent like UIActivityController in iPhone iOS6 我想像iPhone iOS6中的UIActivityController一样保持背景透明
I try to clear color and opaque but background always black like this (iPhone iOS5 simulator) 我尝试清除颜色和不透明,但背景总是像这样(iPhone iOS5模拟器)为黑色
This is presentViewController code: 这是presentViewController代码:
ShareViewController *controller = [[ShareViewController alloc] initWithNibName:@"ShareViewController_iPhone" bundle:nil];
controller.delegate = self;
[self presentViewController:controller animated:YES completion:^{
NSLog(@"Activity complete");
}];
Please help! 请帮忙! Thanks! 谢谢!
See what you have to do is add a UIView
behind the custom UIActionsheet
you mentioned. 看到您要做的是在您提到的自定义UIActionsheet
后面添加一个UIView
。 Here what you can do is keep the Background-color of the UIView
as white and then keep its alpha = 0.5. 在这里,您可以做的是将UIView
的Background-color保持为白色,然后使其alpha = 0.5。
When you dismiss the UIActionsheet
you can removeFromSuperview
the UIView
added behind too. 当您关闭UIActionsheet
您也可以从后面添加UIView
removeFromSuperview
。
Instead of presentViewController use [UIView transitionWithView] to define your custom animation. 代替presentViewController,使用[UIView transitionWithView]定义您的自定义动画。
Start by having your view controller retained somewhere. 首先将视图控制器保留在某处。 (If you are using ARC have it as property on the parent view controller). (如果使用的是ARC,请将其作为父视图控制器的属性)。
Add the view controller's view as a subview to the current VC's view. 将视图控制器的视图作为子视图添加到当前VC的视图。 Set the frame to be CGRectMake(0, screenBottom, screenWidth, screenHeight / 2); 将框架设置为CGRectMake(0,screenBottom,screenWidth,screenHeight / 2);
Animate by changing the frame so that it slides onto the screen. 通过更改框架进行动画处理,使其滑到屏幕上。
[UIView transitionWithView:<#(UIView *)view#> duration:0.5 options:nil animations:^ { view.frame = CGRectMake(0, screenHeight / 2, screenWidth, screenHeight/ 2); } completion:nil];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.