到新公司后,想養(yǎng)成一個好習(xí)慣,寫博客,多做分享,就根據(jù)自己平時的工作內(nèi)容來做分享吧
場景是有一個UIViewController ,點一個按鈕 彈出一個半透明框,然后點擊框上確認(rèn)按鈕,框消失
-(IBAction)buttonClick:(id)sender
{
UIButton * uiButton = (UIButton *)sender;
if(uiButton.tag ==1){
//UIViewController
TransparentController * transparentVC = [[TransparentController alloc] initWithNibName:@"TransparentController" bundle:nil];
if ([[[UIDevice currentDevice] systemVersion] floatValue]>=8.0) {
transparentVC.modalPresentationStyle=UIModalPresentationOverCurrentContext;
}else{
self.modalPresentationStyle=UIModalPresentationOverFullScreen;
}
[self presentViewController:transparentVC animated:YES completion:nil];
}else{
//UIView
UIViewAlert *alert = [UIViewAlert nibInstance];
[alert show];
}
}
具體的demo,我往后后整理出來
github地址:
https://github.com/likaiwork/TransparentViewDemo