Latest 1.0.2
Homepage https://github.com/coderwhy/HYLabel
License MIT
Platforms ios 8.0, requires ARC
Frameworks UIKit
Authors

框架的作用

使用效果

  • 如图所示
  • 并且可以监听点击
  • 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)
    }

Latest podspec

{
    "name": "HYLabel",
    "version": "1.0.2",
    "summary": "[email protected]##-u94feu63a5",
    "homepage": "https://github.com/coderwhy/HYLabel",
    "license": "MIT",
    "authors": {
        "coderwhy": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/coderwhy/HYLabel.git",
        "tag": "1.0.2"
    },
    "source_files": "HYLabel/Source/*.swift",
    "frameworks": "UIKit",
    "requires_arc": true
}

Pin It on Pinterest

Share This