繁体   English   中英

如果UIButton的位置不在其超级视图中但可见,则它可以对touch事件做出响应吗?

[英]Can a UIButton response to touch event if it's position is out of its superview, but it is visible?

如果UIButton的位置不在其超级视图中但可见,则它可以对touch事件做出响应吗?

UIView *view01 = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,200)];
UIButton *button01 = [UIButton buttonWithStyle:UIButtonType:UIButtonTypeRoundedRect];
[button01 addTarget:self action:@selector(testTouch:) forControlEvents:UIControlEventTouchUpInside];
button01.frame = CGRectMake(0, 200, 60, 40);
[view01 addSubview:button01];

- (void)testTouch:(id)sender{
  NSLog(@"Touched.....");
}

......

您还需要将view01添加到视图中。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM