[英]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.