美文网首页
弹出view

弹出view

作者: 盖世英雄的梦想 | 来源:发表于2019-01-07 10:37 被阅读0次
屏幕快照 2019-01-07 上午10.32.32.png

在上面定义全局
{
UIView *view;
UIButton *btn;
}

现在viewDidLoad里写
self.navigationItem.title = @"导航";

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@">" style:UIBarButtonItemStyleDone target:self action:@selector(qq)];

view = [[UIView alloc]initWithFrame:CGRectMake(200, 80, 200, 140)];

view.backgroundColor = [UIColor greenColor];

view.hidden = YES;
[self.view addSubview:view];

然后在外边写
-(void)qq{

view.hidden = NO;
btn = [[UIButton alloc]initWithFrame:CGRectMake(10, 0, 40, 40)];
[btn setTitle:@"❌" forState:UIControlStateNormal];

[btn addTarget:self action:@selector(qq1) forControlEvents:UIControlEventTouchUpInside];

[view addSubview:btn];

}
-(void)qq1{
view.hidden = YES;

}

相关文章

网友评论

      本文标题:弹出view

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