Comments (1)
let contentFont = UIFont.systemFont(ofSize: 15)
let color: UIColor = .red
let text = "abcdefgcnvjkdgjkdfnjkdjnjbfhsjfbdfbvhdsjbvhjbsdhvjbfd"
let content = "abcdefg"
let attr = NSMutableAttributedString(string: text)
attr.bs_font = .systemFont(ofSize: 15)
attr.bs_color = .black
let range = NSString(string: text).range(of: content)
attr.bs_set(attribute: NSAttributedString.Key.font, value: contentFont, range: range)
attr.bs_set(textHighlightRange: range, color: color, backgroundColor: .clear) { (view, text, range, rect) in
print("tap text range:...(range)")
}
let label = BSLabel(frame: self.view.bounds)
label.attributedText = attr
self.view.addSubview(label)
在 Demo 工程里写的可以响应点击事件的啊,应该是你的 Label 响应事件被禁用了,或者超出父视图,父视图用户交互被禁用等原因。
from bstext.
Related Issues (20)
- BSTextDemo会崩溃 HOT 6
- TextDecoration,中划线并不生效 HOT 1
- BSText 会内存泄漏 HOT 5
- TextView 长按滑动预览与选中滑动光标预览,功能没有完善!希望作者完善一下 HOT 1
- iOS12 上面设置文字竖排显示,文字不能被显示TextView和Label都不能被显示
- iOS14的系统,我使用自定义的字体,设置文字大小30,竖排,使用textView,文字不显示设置代码如下。
- always crash
- 暗色模式
- 内存泄漏 HOT 1
- truncationToken的值设置无效 HOT 2
- Manually adding the rootViewController's view to the view hierarchy is no longer supported. HOT 1
- 一次性粘贴进大量文字时,显示空白
- 输入时英文联想词多出空格的问题
- 当使用一些细高或者宽扁的字体,竖向排版字间距会不正常
- 计算阿拉伯语,等相关RTL的,layout的size计算不准确
- 好东西一旦失去维护就变成遗憾 HOT 1
- 当numberOfLines设置为0,truncationToken 不显示
- UIGraphicsBeginImageContext iOS 17 deprecated. HOT 2
- 考虑支持 iOS 13 的 UITextInteraction?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bstext.