如果触摸事件的位置超出其超级视图,UIButton可以响应触摸事件,但它是否可见?

时间:2011-10-14 09:37:37

标签: ios uibutton touch response uicontrol

UIButton可以响应触摸事件,如果它的位置超出其超级视图,但它是否可见?

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.....");
}

.........

1 个答案:

答案 0 :(得分:0)

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