Category给label加扩展类 添加点击事件

Category给label加扩展类 添加点击事件,第1张

概述Category 给label加扩展添加点击事件

下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。

内存溢出小编现在分享给大家,也给大家做个参考。

//.h文件#import <UIKit/UIKit.h>@interface UILabel (hanhan)- (voID)dianjishijian:(ID)target action:(SEL)action;@end//.m文件#import "UILabel+hanhan.h"@implementation UILabel (hanhan)- (voID)dianjishijian:(ID)target action:(SEL)action{    self.userInteractionEnabled  = YES;    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:target action:action];    [self addGestureRecognizer:tap];      }@end//使用    UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(10,50,100,100)];    [label dianjishijian:self action:@selector(btn)];    [self.vIEw addSubvIEw:label];//别忘了导头文件  #import "UILabel+hanhan.h"

以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

总结

以上是内存溢出为你收集整理的Category 给label加扩展类 添加点击事件全部内容,希望文章能够帮你解决Category 给label加扩展类 添加点击事件所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1106862.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-28
下一篇2022-05-28

发表评论

登录后才能评论

评论列表(0条)

    保存