Swift_技巧(5)_ActiveLabel使用,Label添加点击事件

一丶介绍

添加点击事件


Paste_Image.png

二丶使用

第三方:
https://github.com/optonaut/ActiveLabel.swift

自定义方法的使用

var protocolLabel:ActiveLabel? = nil

if  protocolLabel == nil {
    
    protocolLabel = ActiveLabel()
    let customType = ActiveType.custom(pattern: "\\《奇乐现金用户使用协议》")
    protocolLabel?.enabledTypes = [customType]
    protocolLabel?.numberOfLines = 2
    protocolLabel?.text = "点击注册按钮,即表示您同意《奇乐现金用户使用协议》"
    protocolLabel?.font = kFontSize_14
    protocolLabel?.customColor[customType] = kColor_459ACA
    protocolLabel?.textColor = kColor_TabBar_normal
    protocolLabel?.handleCustomTap(for: customType, handler: { (customType) in
        print("1111111")
    })
    self.view.addSubview(protocolLabel!)
    protocolLabel?.frame = CGRect.init(x: 0, y: 0, width: 182, height: 40)
    protocolLabel?.center = CGPoint.init(x: kScreenW * 0.5, y: 518)
}

三丶总结

挺方便的.

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 175,776评论 25 709
  • 发现 关注 消息 iOS 第三方库、插件、知名博客总结 作者大灰狼的小绵羊哥哥关注 2017.06.26 09:4...
    肇东周阅读 14,241评论 4 61
  • afinalAfinal是一个android的ioc,orm框架 https://github.com/yangf...
    passiontim阅读 15,714评论 2 45
  • 今天突然想到一个梗:每天早晨叫醒你的,不是梦想,而是闹钟。 一个老梗了。笑笑之余,猛然间脑子一阵空白——我的梦想是...
    谁用了我的尼瓦纳阅读 1,443评论 0 0
  • 落伍阅读 3,060评论 0 0