Ios 在iPhone中显示ViewController时,如何保持背景透明?

Ios 在iPhone中显示ViewController时,如何保持背景透明?,ios,uiviewcontroller,Ios,Uiviewcontroller,我想保持背景透明,就像iPhone iOS6中的UIActivityController一样 我试图清除颜色和不透明,但背景总是像这样的黑色(iPhone iOS5模拟器) 这是presentViewController代码: ShareViewController *controller = [[ShareViewController alloc] initWithNibName:@"ShareViewController_iPhone" bundle:nil]; cont

我想保持背景透明,就像iPhone iOS6中的UIActivityController一样

我试图清除颜色和不透明,但背景总是像这样的黑色(iPhone iOS5模拟器)

这是presentViewController代码:

    ShareViewController *controller = [[ShareViewController alloc] initWithNibName:@"ShareViewController_iPhone" bundle:nil];
    controller.delegate = self;

    [self presentViewController:controller animated:YES completion:^{
        NSLog(@"Activity complete");
    }];

请帮忙!谢谢

看看你要做的是在你提到的自定义
ui操作表
后面添加一个
ui视图
。在这里,您可以将
UIView
的背景色保持为白色,然后保持其alpha=0.5


当您关闭
UIActionsheet
时,您可以
从SuperView中移除后面添加的
UIView

而不是presentViewController使用[UIView transitionWithView]定义自定义动画

  • 首先,将视图控制器保留在某个位置。(如果使用的是圆弧,请将其作为父视图控制器上的属性)

  • 将视图控制器的视图作为子视图添加到当前VC的视图中。将框架设置为CGRectMake(0,屏幕底部,屏幕宽度,屏幕高度/2)

  • 通过更改帧使其滑动到屏幕上来设置动画

    [UIView transitionWithView:<#(UIView *)view#> duration:0.5 options:nil
      animations:^
      {
          view.frame = CGRectMake(0, screenHeight / 2, screenWidth, screenHeight/ 2);
      } completion:nil];
    
    [UIView transitionWithView:duration:0.5选项:无
    动画:^
    {
    view.frame=CGRectMake(0,屏幕高度/2,屏幕宽度,屏幕高度/2);
    }完成:无];
    

您需要将此控制器的视图作为子视图添加到另一个视图中。背景为黑色,因为在presentViewController完成后,显示控制器的视图将从窗口的视图层次结构中删除。