iOS 模态出一个半透明的ViewController

FirstVC:

UIViewController*testVC = [[UIViewControlleralloc]init];

/*

FirstVC 上控件

UITextField*field = [[UITextFieldalloc]initWithFrame:CGRectMake(0,0,200,40)];

field.layer.borderWidth=1;

field.layer.cornerRadius=2;

field.clipsToBounds=YES;

field.backgroundColor=[UIColorredColor];


UIButton*paperBtn = [[UIButtonalloc]initWithFrame:CGRectMake(60,0,200,40)];

paperBtn.backgroundColor=UIColorFromRGBA(0xb8b8b8,1);

paperBtn.layer.cornerRadius=4.;

paperBtn.layer.masksToBounds=YES;

[paperBtnsetTitle:@"完成"forState:UIControlStateNormal];

[paperBtnaddTarget:selfaction:@selector(Click:)forControlEvents:UIControlEventTouchUpInside];


UIView*view = [[UIViewalloc]initWithFrame:CGRectMake(0,0,SCREEN_H*0.5,SCREEN_W*0.5)];

view.backgroundColor= [UIColorgrayColor];


[viewaddSubview:field];

[viewaddSubview:paperBtn];

[testVC.viewaddSubview:view];

*/

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

testVC.view.backgroundColor= [UIColorcolorWithRed:0green:0blue:0alpha:.4];

testVC.modalPresentationStyle=UIModalPresentationOverCurrentContext;

[selfpresentViewController:testVCanimated:YEScompletion:nil];

2,SecondVC:

UIViewController = SecondVC ; 

你可能感兴趣的:(iOS 模态出一个半透明的ViewController)