UI的实现项目可能用

iOS 模态出一个半透明的ViewController

2017-02-16  本文已影响27人  其实也没有

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 ; 

上一篇下一篇

猜你喜欢

热点阅读