#import “ViewController.h”
@interface ViewController ()
@property (nonatomic,strong) UIView * maskTheView;
@property (nonatomic,strong) UIView * shareView;
@end
@implementation ViewController
-
(void)viewDidLoad {
[super viewDidLoad];
[self.view addSubview:self.maskTheView];
[self.view addSubview:self.shareView];
} -
(UIView *)maskTheView{
if (!_maskTheView) {
_maskTheView = [[UIView alloc]initWithFrame:[UIScreen mainScreen].bounds];
_maskTheView.backgroundColor = [UIColor colorWithRed:0/255.f green:0/255.f blue:0/255.f alpha:0.5];
//添加一个点击手势
UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(maskClickGesture)];
[_maskTheView addGestureRecognizer:tap];//让header去检测点击手势
}
return _maskTheView;
} -
(UIView *)shareView{
if (!_shareView) {
_shareView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 160)];
_shareView.center = CGPointMake(self.view.frame.size.width/2, self.view.frame.size.height/2);
_shareView.backgroundColor = [UIColor whiteColor];}
return _shareView;
} -
(void)maskClickGesture{
[self.maskTheView removeFromSuperview];
[self.shareView removeFromSuperview];
}
@end