亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

iOS:具有透明背景的Modal ViewController

iOS:具有透明背景的Modal ViewController

翻翻過去那場雪 2019-12-09 10:37:13
我正在嘗試以透明背景模態呈現視圖控制器。我的目標是讓呈現和呈現的視圖控制器的視圖同時顯示。問題是,當演示動畫結束時,演示視圖控制器的視圖消失。- (IBAction)pushModalViewControllerButtonPressed:(id)sender{    ModalViewController *modalVC = [[ModalViewController alloc] init];    [self presentViewController:modalVC animated:YES completion:nil];}我知道我可以將視圖添加為子視圖,但是出于某種原因,我想避免這種解決方案。我該如何解決?
查看完整描述

3 回答

?
www說

TA貢獻1775條經驗 獲得超8個贊

以下代碼僅適用于iPad。


self.view.backgroundColor = [UIColor clearColor];

self.modalPresentationStyle = UIModalPresentationCurrentContext;

[self presentModalViewController:modalVC animated:YES];

我會添加一個子視圖。


這是一個很好的討論。具體看一下評論。不只是答案。


模態視圖


如果我是你,我不會做。我將添加一個子視圖并執行此操作??磥砦铱梢愿玫乜刂剖挛?。


編輯:


正如Paul Linsay所提到的,自iOS 8起,所需要的只是UIModalPresentationOverFullScreen用于呈現ViewController的modalPresentationStyle。這也將覆蓋navigationBar和tabBar按鈕。


查看完整回答
反對 回復 2019-12-09
?
不負相思意

TA貢獻1777條經驗 獲得超10個贊

在iOS 8.0及更高版本中,可以通過將modalPresentationStyle屬性設置為UIModalPresentationOverCurrentContext來完成


//Set property **definesPresentationContext** YES to avoid presenting over presenting-viewController's navigation bar


self.definesPresentationContext = YES; //self is presenting view controller

presentedController.view.backgroundColor = [YOUR_COLOR with alpha OR clearColor]

presentedController.modalPresentationStyle = UIModalPresentationOverCurrentContext;


[self presentViewController:presentedController animated:YES completion:nil];


查看完整回答
反對 回復 2019-12-09
  • 3 回答
  • 0 關注
  • 1287 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號