第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

在UIViewController上顯示clearColor UIViewController

在UIViewController上顯示clearColor UIViewController

九州編程 2019-10-05 11:29:25
我UIViewController在另一個UIViewController視圖之上有一個視圖作為子視圖/模態(tài),例如,子視圖/模態(tài)應(yīng)該是透明的,添加到子視圖中的任何組件都應(yīng)該是可見的。問題是我所擁有的是子視圖顯示黑色背景而不是clearColor。我試圖將其UIView作為clearColor而不是黑色背景。有人知道這是怎么回事嗎?任何建議表示贊賞。FirstViewController.mUIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];[vc setModalPresentationStyle:UIModalPresentationFullScreen];[self presentModalViewController:vc animated:NO];  SecondViewController.m- (void)viewDidLoad {     [super viewDidLoad];     self.view.opaque = YES;     self.view.backgroundColor = [UIColor clearColor];}解決:我已解決問題。它對于iPhone和iPad都運(yùn)行良好。沒有黑色背景的模態(tài)視圖控制器只是clearColor / transparent。我唯一需要更改的是替換UIModalPresentationFullScreen為UIModalPresentationCurrentContext。多么簡單!FirstViewController.mUIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];UIViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"SecondViewController"];vc.view.backgroundColor = [UIColor clearColor];self.modalPresentationStyle = UIModalPresentationCurrentContext;[self presentViewController:vc animated:NO completion:nil];注意:壞消息是上述解決方案無法在iOS 7上運(yùn)行。好消息是我已修復(fù)iOS7的問題!我向某人求助,這是他說的話:當(dāng)以模態(tài)方式顯示視圖控制器時,iOS在顯示期間將其下方的視圖控制器從視圖層次結(jié)構(gòu)中移除。雖然以模態(tài)形式顯示的視圖控制器的視圖是透明的,但在其下方除了黑色的應(yīng)用程序窗口外沒有其他任何東西。iOS 7引入了一種新的模式表示樣式,UIModalPresentationCustom該樣式使iOS不會刪除所顯示視圖控制器下方的視圖。但是,為了使用這種模式表示樣式,必須提供自己的過渡委托來處理表示并關(guān)閉動畫。WWDC 2013 https://developer.apple.com/wwdc/videos/?id=218的“使用視圖控制器的自定義過渡”演講中對此進(jìn)行了概述,該演講還介紹了如何實現(xiàn)自己的過渡委托。您可能會在iOS7中看到我針對上述問題的解決方案:https : //github.com/hightech/iOS-7-Custom-ModalViewController-Transitions
查看完整描述

3 回答

?
紅糖糍粑

TA貢獻(xiàn)1815條經(jīng)驗 獲得超6個贊

iOS8以上


在iOS8 +中,您現(xiàn)在可以使用新的modalPresentationStyle UIModalPresentationOverCurrentContext來呈現(xiàn)具有透明背景的視圖控制器:


MyModalViewController *modalViewController = [[MyModalViewController alloc] init];

modalViewController.modalPresentationStyle = UIModalPresentationOverCurrentContext;           

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


查看完整回答
反對 回復(fù) 2019-10-05
?
素胚勾勒不出你

TA貢獻(xiàn)1827條經(jīng)驗 獲得超9個贊

Swift 3和iOS10解決方案:


//create view controller

let vc = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "RoadTripPreviewViewController")

//remove black screen in background

vc.modalPresentationStyle = .overCurrentContext

//add clear color background

vc.view.backgroundColor = UIColor.clear

//present modal

self.present(vc, animated: true, completion: nil)


查看完整回答
反對 回復(fù) 2019-10-05
  • 3 回答
  • 0 關(guān)注
  • 857 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號