您的位置:首页 > 产品设计 > UI/UE

UIView点击事件。弹出视图,背景虚化。

2016-07-20 17:11 323 查看
@interface CountryViewController

//背景

@property (strong, nonatomic) UIView *BackView;

end

//设置背景虚化

-(UIView *)BackView{

if (!_BackView) {

_BackView = [[UIView alloc]initWithFrame:self.view.bounds];

//背景虚化

UIColor *myColor = [UIColor colorWithWhite:0.5 alpha:0.5];

_BackView.backgroundColor = myColor;

[self.view addSubview:self.BackView];

//设置在当前控制器前面

[self.view bringSubviewToFront:self.BackView];

//一开始隐藏

self.BackView.hidden = YES;

//添加点击事件

UITapGestureRecognizer *tapGesture = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(actiondo)];

[_BackView addGestureRecognizer:tapGesture];

}

return _BackView;

}

//实现方法

-(void)actiondo{

NSLog(@"1231231231231231231231231231231");

}

//设置一个按钮事件

-(void)click{

  //显示UIview

  self.BackView.hidden = NO;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: