hyl

HYLabel

用于识别Label中的@用户-话题##-链接

Showing:

Popularity

Downloads/wk

0

GitHub Stars

169

Maintenance

Last Commit

5yrs ago

Contributors

2

Package

Dependencies

0

License

MIT

Categories

Readme

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)
    }

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100