Comments (3)
这个库,按照作者的回复,应该是基于 NSAttributedString
,所以在确定range
的时候,应该先将Swift.String
转化成NSString
。比如:
let length = "🤔".count
let range = NSRange(location: 0, length: length)
应该改成:
let length = ("🤔" as NSString).length
let range = NSRange(location: 0, length: length)
我脱机敲的,不知道准不准确。
from attributedstring.
等价于调用
func setAttributes(_ attrs: [NSAttributedString.Key : Any]?, range: NSRange)
你可以用
public mutating func add(attributes: [Attribute], range: NSRange) {
from attributedstring.
或者可以用"🤔".utf8.count 等于 ("🤔" as NSString).length
from attributedstring.
Related Issues (20)
- ViewAttachment 能否将view开放出来 HOT 4
- 添加Action的情况下 文字颜色始终是蓝色,怎么修改呢 HOT 2
- AttributedString.swift文件中别名的问题 HOT 1
- TextView 图片偏移显示不全 HOT 2
- XCode14打包在iOS12设备上崩溃问题 HOT 5
- 挺喜欢这个库,但是使用的时候遇到了一些问题 HOT 15
- UIButton下action点击无效 HOT 1
- 点击事件崩溃 HOT 3
- iOS16 UITextView 默认使用的TextKit2 如遇到问题 可以切换到 TextKit 1
- 如何在SwiftUI中使用? HOT 1
- Build error with Objective-C project HOT 1
- How to create from HTML? HOT 1
- UITextView 如果设置了 isSelectable = false HOT 1
- Crash at Action.swift HOT 1
- UITextView 如果设置了 isSelectable = true 就不能触发点击事件 HOT 1
- 高亮时的样式可以默认用非高亮的样式吗? HOT 4
- 是否可替换富文本内容?
- 一个建议:增加链式调用 HOT 1
- 可以支持swiftUI吗 HOT 1
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 attributedstring.