2013-08-02 55 views
2

我想保持背景透明狀UIActivityController在iPhone iOS6的 enter image description here如何在iPhone中使用presentViewController時保持背景透明?

我嘗試清除顏色和不透明的,但背景總是黑色這樣的(iPhone的iOS5模擬器)

enter image description here

這是presentViewController代碼:

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

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

請幫忙!謝謝!

+0

您需要添加該控制器的視圖作爲一個子視圖到另一視圖。 –

+3

背景是黑色的,因爲在presentViewController完成後,呈現控制器的視圖將從窗口的視圖層次結構中移除。 – rdelmar

回答

1

看到你要做的是在你提到的自定義UIActionsheet之後添加一個UIView。在這裏你可以做的是保持UIView的Background-color爲白色,然後保持alpha = 0.5。

當您關閉UIActionsheet時,您可以在removeFromSuperview之後添加UIView

0

而不是presentViewController使用[UIView transitionWithView]來定義您的自定義動畫。

  • 首先讓您的視圖控制器保留在某處。 (如果您使用ARC,則將其作爲父視圖控制器上的屬性)。

  • 將視圖控制器視圖添加爲當前VC視圖的子視圖。將框架設置爲CGRectMake(0,screenBottom,screenWidth,screenHeight/2);

  • 通過更改框架使其滑動到屏幕上來動畫。

    [UIView transitionWithView:<#(UIView *)view#> duration:0.5 options:nil 
        animations:^ 
        { 
         view.frame = CGRectMake(0, screenHeight/2, screenWidth, screenHeight/ 2); 
        } completion:nil];