简体   繁体   English

如何在iPhone中使用presentViewController时保持背景透明?

[英]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.

相关问题 视图presentViewController的透明背景 - transparent background of the view presentViewController presentViewController黑色背景而不是透明 - presentViewController black background instead of transparent presentViewController透明背景在iPad 4上不起作用 - presentViewController transparent background doesn't work on iPad 4 iPhone:当其他视图存在时,如何防止关闭键盘 - iPhone : how to prevent dismiss keyboard when other view presentViewController Iphone如何使上下文背景透明? - Iphone How to make context background transparent? 解析后的网页背景在iphone中不透明 - parsed webpage background is not transparent in iphone 在viewController或NavigationController上调用presentViewController时,该如何工作? - How presentViewController works when called on viewController or on NavigationController? 将presentViewController与UITabbarController一起使用时如何传递数据 - How to passing data when using presentViewController with UITabbarController iPhone,iOS 8:如何将presentViewController小于原始视图控制器? - iPhone, iOS 8: How to presentViewController smaller than original view controller? iphone-为CAShapeLayer * maskLayer提供透明背景 - iphone-give transparent background to CAShapeLayer *maskLayer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM