CocoaPods trunk is moving to be read-only. Read more on the blog, there are 18 months to go.

HYLabel 1.0.2

HYLabel 1.0.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Apr 2016
SPMSupports SPM

Maintained by honey9521.



HYLabel 1.0.2

  • By
  • coderwhy

HYLabel

框架的作用

使用效果

  • 如图所示
  • 并且可以监听点击
  • image

使用方式

  • 导入框架
    • 直接将HYLabel.swift拖入项目
    • 该框架支持cocoapods:pod ‘HYLabel’, ’~> 1.0.1’

  • 将UIlabel修改为HYLabel
  • 按照下列方式监听点击即可
  • OC监听方式
    self.demoLabel.userTapHandler = ^(HYLabel *label, NSString *user, NSRange range){
        NSLog(@"%@", label);
        NSLog(@"%@", user);
        NSLog(@"%@", NSStringFromRange(range));
    };

    self.demoLabel.linkTapHandler = ^(HYLabel *label, NSString *link, NSRange range){
        NSLog(@"%@", label);
        NSLog(@"%@", link);
        NSLog(@"%@", NSStringFromRange(range));
    };

    self.demoLabel.userTapHandler = ^(HYLabel *label, NSString *topic, NSRange range){
        NSLog(@"%@", label);
        NSLog(@"%@", topic);
        NSLog(@"%@", NSStringFromRange(range));
    };
  • swift监听方式
    // 监听@谁谁谁的点击
    demoLabel.userTapHandler = { (label, user, range) in
        print(label)
        print(user)
        print(range)
    }

    // 监听链接的点击
    demoLabel.linkTapHandler = { (label, link, range) in
        print(label)
        print(link)
        print(range)
    }

    // 监听话题的点击
    demoLabel.topicTapHandler = { (label, topic, range) in
        print(label)
        print(topic)
        print(range)
    }