UILable怎样加入单击事件

//初始化UILable
UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(60, 0, 320, 40)];  
 //设置其能够接收用户交互的事件(默认情况下为NO)
  lable.userInteractionEnabled=YES;  
//创建一个手势事件
 UITapGestureRecognizer *labelTapGestureRecognizer = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(labelTouchUpInside:)]; 
//UILable与事件绑定
 [lable addGestureRecognizer:labelTapGestureRecognizer];  

posted @ 2017-05-06 14:47  mfmdaoyou  阅读(237)  评论(0编辑  收藏  举报