弹出view

弹出view_第1张图片
屏幕快照 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)