// 1. 創(chuàng)建一個點擊事件委煤,點擊時觸發(fā)labelClick方法?
?UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(labelClick)];
? ? UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 200, 100)];
? ? // 2. 將點擊事件添加到label上? ??
[label addGestureRecognizer:labelTapGestureRecognizer];
label.userInteractionEnabled = YES; // 可以理解為設(shè)置label可被點擊//?
3. 在此方法中設(shè)置點擊label后要觸發(fā)的操作
- (void)labelClick {
}