美文网首页UI的实现项目可能用
iOS 模态出一个半透明的ViewController

iOS 模态出一个半透明的ViewController

作者: 其实也没有 | 来源:发表于2017-02-16 15:04 被阅读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 ; 

相关文章

网友评论

    本文标题:iOS 模态出一个半透明的ViewController

    本文链接:https://www.haomeiwen.com/subject/jwavyttx.html