在一个superview中,添加了一个subview。tap一下superview,将subview隐藏起来。
在视图superview添加一个UITapGestureRecognizer对象,在UITapGestureRecognizer对象的action中实现隐藏subview的逻辑代码。
UIView *superview = [[UIView alloc] initWithFrame:CGRectMake:(0, 0, 320, 480);
UIView *subview = [[UIView alloc] initWithFrame:CGRectMake:(100, 100, 100, 100);
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget: self action: @selector(handleTap);
[superview addGestureRecognizer:recognizer];
[self.view addSubview:superview];
[superview addSubview:subview];