{"id":13696333,"url":"https://github.com/lyb5834/YBAttributeTextTapAction","last_synced_at":"2025-05-03T17:30:51.056Z","repository":{"id":56928859,"uuid":"62380841","full_name":"lyb5834/YBAttributeTextTapAction","owner":"lyb5834","description":"一行代码添加文本点击事件/a fast way to implement click event text","archived":false,"fork":false,"pushed_at":"2019-03-25T07:32:16.000Z","size":2532,"stargazers_count":464,"open_issues_count":15,"forks_count":88,"subscribers_count":9,"default_branch":"master","last_synced_at":"2025-03-26T17:18:46.033Z","etag":null,"topics":["attribute","click","coretext","label","link","nsmutableparagraphstyle","tap","text"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/lyb5834.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-01T09:17:28.000Z","updated_at":"2024-11-18T07:49:26.000Z","dependencies_parsed_at":"2022-08-21T06:20:18.515Z","dependency_job_id":null,"html_url":"https://github.com/lyb5834/YBAttributeTextTapAction","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyb5834%2FYBAttributeTextTapAction","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyb5834%2FYBAttributeTextTapAction/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyb5834%2FYBAttributeTextTapAction/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lyb5834%2FYBAttributeTextTapAction/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lyb5834","download_url":"https://codeload.github.com/lyb5834/YBAttributeTextTapAction/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251543641,"owners_count":21606494,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["attribute","click","coretext","label","link","nsmutableparagraphstyle","tap","text"],"created_at":"2024-08-02T18:00:38.548Z","updated_at":"2025-05-03T17:30:50.495Z","avatar_url":"https://github.com/lyb5834.png","language":"Objective-C","funding_links":[],"categories":["UI Components"],"sub_categories":[],"readme":"# YBAttributeTextTapAction\n * 一行代码添加文本点击事件\n\n# 效果图\n![(演示效果)](https://lyb5834.github.io/Images/attributeTapAction.gif)\n\n# Swfit版本（最新版还未更新，可直接集成OC版本）\nhttps://github.com/lyb5834/YBAttributeTextTapForSwfit.git\n\n# 使用方法\n  * `#import \"UILabel+YBAttributeTextTapAction.h\"`\n  * 先设置 `label.attributedText = ？？？？？` \n  * 有2种回调方法，第一种是用代理回调，第二种是用block回调\n  * 代理回调\n  *  1.传入要点击的字符串数组\n   ```\n   [label yb_addAttributeTapActionWithStrings:@[@\"xxx\",@\"xxx\"] delegate:self];\n   ```\n  *  2.传入要点击的range数组\n   ```\n   [label yb_addAttributeTapActionWithRanges:@[NSStringFromRange(range1),NSStringFromRange(range2)] delegate:self]\n   ```\n  * block回调\n  * 1.传入要点击的字符串数组 \n   ```\n   [label yb_addAttributeTapActionWithStrings:@[@\"xxx\",@\"xxx\"] tapClicked:^(UILabel *label,NSString *string, NSRange range,NSInteger index) {  coding more... }];\n   ```\n  * 2.传入要点击的range数组 \n   ```\n   [label yb_addAttributeTapActionWithRanges:@[NSStringFromRange(range1),NSStringFromRange(range2)] tapClicked:^(UILabel *label,NSString *string, NSRange range,NSInteger index) {  coding more... }];\n   ```\n\n# CocoaPods支持\n  * 只需在podfile中输入 `pod 'YBAttributeTextTapAction'` 即可\n\n# V3.0.3版本\n  * 增加`yb_removeAttributeTapActions`方法，可以删除label上所有的附加点击事件，一般用于复用的cell，防止label上还存在不必要的点击事件\n\n# V3.0.2版本\n  * 修复了在8.0系统上crash 的bug\n\n# V3.0.1版本\n  * 修复字符串中有多个\"\\n\"符号时计算不准确的bug\n  \n# V3.0.0版本\n  * 重构计算文字坐标的算法，点击准确率大大提升（再大的文本都不怕啦）\n  * 重构API，回调参数更多\n  * 增加传入range数组的API，可以指定range进行触发\n  * 增加设置点击高亮色和是否扩大点击区域的API，麻麻再也不用担心我手指粗点不到啦\n  * 重构demo，介绍更详细，用法更丰富\n  * 修复一个页面多次调用会相互影响的bug\n  * 修复在label上添加手势无效的bug\n  \n# 问题总结\n  *  因为UILabel的封装，有些属性不能实现，在此说一下一些提的比较多的问题\n  \n  ###  必须设置字体属性,不然点击范围会不准确，重要的事情说三遍\n  ###  必须设置字体属性！必须设置字体属性！必须设置字体属性！\n  \n  eg:\n   ```\n   [totalStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:orginFont] range:NSMakeRange(0, string.length)];\n   ```\n  * 关于文字排版的正确设置方式，设置`label.textAlignment = NSTextAlignmentCenter`会导致点击失效，正确的设置方法是    \n  ```\n      NSMutableParagraphStyle *sty = [[NSMutableParagraphStyle alloc] init];\n     sty.alignment = NSTextAlignmentCenter;\n     [attributedString addAttribute:NSParagraphStyleAttributeName value:sty range:NSMakeRange(0, text.length)];\n   ```\n\n# 版本支持\n  * `xcode6.0+`\n\n  * 如果您在使用本库的过程中发现任何bug或者有更好建议，欢迎[@issues](https://github.com/lyb5834/YBAttributeTextTapAction/issues) 或联系本人email  lyb5834@126.com\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyb5834%2FYBAttributeTextTapAction","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flyb5834%2FYBAttributeTextTapAction","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flyb5834%2FYBAttributeTextTapAction/lists"}