bottomView上添加了一个手势,bottomView上增加了topView,topView上加了一个button
然后在topView上移动,依然能收到手势对应的方法,在button上移动也能收到手势对应的方法
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
UIView *bottomView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
bottomView.backgroundColor = [UIColor greenColor];
UIPanGestureRecognizer *pan = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(pan:)];
[bottomView addGestureRecognizer:pan];
[self.view addSubview:bottomView];
UIView *topView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 200)];
topView.backgroundColor = [UIColor brownColor];
topView.userInteractionEnabled = YES;
[bottomView addSubview:topView];
UIButton *btn = [UIButton buttonWithType:UIButtonTypeRoundedRect];
btn.frame = CGRectMake(0, 0, 60, 30);
[btn addTarget:self action:@selector(bbb:) forControlEvents:UIControlEventTouchUpInside];
[topView addSubview:btn];
}
- (void)pan:(UIPanGestureRecognizer *)panGes
{
NSLog(@"fan pan ");
}
- (void)bbb:(id)sender
{
NSLog(@"button press");
}