2013-04-08 68 views
1

我的UIViewController稱爲TestVC誰的背景設定爲clearColor:UIModalPresentationCurrentContext不顯示背景透明

@implementation TestVC 

- (void)viewDidLoad { 
    [super viewDidLoad]; 
    self.view.backgroundColor = [UIColor clearColor]; 
} 

@end 

我通過從另一個視圖控制器呈現TestVC:

self.modalPresentationStyle = UIModalPresentationCurrentContext; 
[self presentViewController:[[TestVC alloc] init] animated:YES completion:NULL]; 

但本TestVC是白色的它遮擋了屏幕。有沒有辦法讓它透明或部分遮掩底層視圖控制器?

感謝

+1

什麼是窗口的顏色,並嘗試modalPresentationStyle UIModalPresentationStyleFormSheet。 – satheeshwaran 2013-04-08 04:12:06

+0

就像答案建議的那樣,設置TestVC實例的modalPresentationStyle,而不是這樣做到「自我」。 – alasker 2017-02-15 14:58:52

回答

0

抱歉..我的錯......就像在下面評論,你必須設置你要呈現的視圖控制器。 此行添加到您目前的TestVC TestVCClass *TestVC =[[TestVCClass alloc]init]; TestVC.modalPresentationStyle = UIModalPresentationOverCurrentContext; [self presentViewController:TestVC animated:YES completion:nil];

+0

呃......這兩條線都是一樣的!你是否想要在第二個實例中更改'modalPresentationStyle'? – 2017-02-10 11:22:48

0

嘗試在TestVC,而不是在做呈現視圖控制器設置modalPresentationStyle控制器。如果UIModalPresentationCurrentContext仍然不起作用,請嘗試UIModalPresentationCustom