美文网首页ios开发记录iOS
UIViewController弹出一个透明的UIViewCon

UIViewController弹出一个透明的UIViewCon

作者: selice | 来源:发表于2018-05-21 11:57 被阅读75次

在第一个UIViewController事件中

 TestController *tView = [[TestController alloc] init];

    //设置模式展示风格

    [tViewsetModalPresentationStyle:UIModalPresentationOverCurrentContext];

    //必要配置

    self.modalPresentationStyle = UIModalPresentationCurrentContext;

    self.providesPresentationContextTransitionStyle = YES;

    self.definesPresentationContext = YES;

    [self presentViewController:tView animated:NO completion:nil];

在弹出的TestController.m中重写

#define DeviceHeight [[UIScreen mainScreen] bounds].size.height

#define DeviceWidth [[UIScreen mainScreen] bounds].size.width

/**

 *  设置位置宽高

 */

- (void)viewWillLayoutSubviews {

    self.view.frame = CGRectMake(0, 0, DeviceWidth, DeviceHeight);

    self.view.backgroundColor = [UIColor colorWithWhite:0.5 alpha:.5];

    //self.view.backgroundColor = [UIColor clearColor];

    //self.view.backgroundColor = [UIColor colorWithRed:1 green:0 blue:0 alpha:0.868f];

}

相关文章

网友评论

    本文标题:UIViewController弹出一个透明的UIViewCon

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