All Projects → lyb5834 → Ybattributetexttapaction

lyb5834 / Ybattributetexttapaction

Licence: mit
一行代码添加文本点击事件/a fast way to implement click event text

Projects that are alternatives of or similar to Ybattributetexttapaction

Attributedstring
基于Swift插值方式优雅的构建富文本, 支持点击长按事件, 支持不同类型过滤, 支持自定义视图等.
Stars: ✭ 294 (-31.63%)
Mutual labels:  text, click, label
Dzhtmltext
Delphi and Lazarus HTML Label component
Stars: ✭ 60 (-86.05%)
Mutual labels:  label, link
Ybattributetexttapforswfit
一行代码添加文本点击事件(swfit4.2版本)/a fast way to implement click event text(for swfit4.2)
Stars: ✭ 47 (-89.07%)
Mutual labels:  text, label
React Native Hyperlink
A <Hyperlink /> component for react-native that makes urls, fuzzy links, emails etc clickable
Stars: ✭ 572 (+33.02%)
Mutual labels:  text, link
Tytext
text asynchronous rendering by TextKit for iOS
Stars: ✭ 127 (-70.47%)
Mutual labels:  text, label
Mpitextkit
Powerful text framework for iOS to display rich text based on TextKit, inspired by Texture and YYText.
Stars: ✭ 191 (-55.58%)
Mutual labels:  text, label
link text
Easy to use text widget for Flutter apps, which converts inlined urls into working, clickable links
Stars: ✭ 20 (-95.35%)
Mutual labels:  text, link
JHTapTextView
Tap TextView,Text Tap,文本点击
Stars: ✭ 23 (-94.65%)
Mutual labels:  tap, click
react-native-double-click
A Component Wrapper for Double Click/Tap
Stars: ✭ 42 (-90.23%)
Mutual labels:  tap, click
Matchzoo Py
Facilitating the design, comparison and sharing of deep text matching models.
Stars: ✭ 362 (-15.81%)
Mutual labels:  text
Mle
Flexible terminal-based text editor (C)
Stars: ✭ 378 (-12.09%)
Mutual labels:  text
Textillate
A jquery plugin for CSS3 text animations.
Stars: ✭ 3,590 (+734.88%)
Mutual labels:  text
Nlp
[UNMANTEINED] Extract values from strings and fill your structs with nlp.
Stars: ✭ 367 (-14.65%)
Mutual labels:  text
Ava
Node.js test runner that lets you develop with confidence 🚀
Stars: ✭ 19,458 (+4425.12%)
Mutual labels:  tap
Baretest
An extremely fast and simple JavaScript test runner.
Stars: ✭ 364 (-15.35%)
Mutual labels:  tap
Pytorch Widedeep
A flexible package to combine tabular data with text and images using Wide and Deep models in Pytorch
Stars: ✭ 416 (-3.26%)
Mutual labels:  text
Android Text
Migrated:
Stars: ✭ 358 (-16.74%)
Mutual labels:  text
Doctest
An experimental tool for testing Swift example code in documentation.
Stars: ✭ 358 (-16.74%)
Mutual labels:  tap
Inputkit
📝InputKit, an Elegant Kit to limits your input text, inspired by BlocksKit, written in both Objective-C & ⚡️Swift.
Stars: ✭ 420 (-2.33%)
Mutual labels:  text
Crayons
Text UI colors for Python.
Stars: ✭ 409 (-4.88%)
Mutual labels:  text

YBAttributeTextTapAction

  • 一行代码添加文本点击事件

效果图

(演示效果)

Swfit版本(最新版还未更新,可直接集成OC版本)

https://github.com/lyb5834/YBAttributeTextTapForSwfit.git

使用方法

  • #import "UILabel+YBAttributeTextTapAction.h"
  • 先设置 label.attributedText = ?????
  • 有2种回调方法,第一种是用代理回调,第二种是用block回调
  • 代理回调
  • 1.传入要点击的字符串数组
[label yb_addAttributeTapActionWithStrings:@[@"xxx",@"xxx"] delegate:self];
  • 2.传入要点击的range数组
[label yb_addAttributeTapActionWithRanges:@[NSStringFromRange(range1),NSStringFromRange(range2)] delegate:self]
  • block回调
  • 1.传入要点击的字符串数组
[label yb_addAttributeTapActionWithStrings:@[@"xxx",@"xxx"] tapClicked:^(UILabel *label,NSString *string, NSRange range,NSInteger index) {  coding more... }];
  • 2.传入要点击的range数组
[label yb_addAttributeTapActionWithRanges:@[NSStringFromRange(range1),NSStringFromRange(range2)] tapClicked:^(UILabel *label,NSString *string, NSRange range,NSInteger index) {  coding more... }];

CocoaPods支持

  • 只需在podfile中输入 pod 'YBAttributeTextTapAction' 即可

V3.0.3版本

  • 增加yb_removeAttributeTapActions方法,可以删除label上所有的附加点击事件,一般用于复用的cell,防止label上还存在不必要的点击事件

V3.0.2版本

  • 修复了在8.0系统上crash 的bug

V3.0.1版本

  • 修复字符串中有多个"\n"符号时计算不准确的bug

V3.0.0版本

  • 重构计算文字坐标的算法,点击准确率大大提升(再大的文本都不怕啦)
  • 重构API,回调参数更多
  • 增加传入range数组的API,可以指定range进行触发
  • 增加设置点击高亮色和是否扩大点击区域的API,麻麻再也不用担心我手指粗点不到啦
  • 重构demo,介绍更详细,用法更丰富
  • 修复一个页面多次调用会相互影响的bug
  • 修复在label上添加手势无效的bug

问题总结

  • 因为UILabel的封装,有些属性不能实现,在此说一下一些提的比较多的问题

必须设置字体属性,不然点击范围会不准确,重要的事情说三遍

必须设置字体属性!必须设置字体属性!必须设置字体属性!

eg:

[totalStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:orginFont] range:NSMakeRange(0, string.length)];
  • 关于文字排版的正确设置方式,设置label.textAlignment = NSTextAlignmentCenter会导致点击失效,正确的设置方法是
    NSMutableParagraphStyle *sty = [[NSMutableParagraphStyle alloc] init];
   sty.alignment = NSTextAlignmentCenter;
   [attributedString addAttribute:NSParagraphStyleAttributeName value:sty range:NSMakeRange(0, text.length)];

版本支持

  • xcode6.0+

  • 如果您在使用本库的过程中发现任何bug或者有更好建议,欢迎@issues 或联系本人email [email protected]

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].