gpt4 book ai didi

ios - NSRangePointer 错误 swift

转载 作者:搜寻专家 更新时间:2023-11-01 06:18:08 24 4
gpt4 key购买 nike

这就是我要实现的目标:

var range : NSRange? = NSMakeRange(0, (attributedString?.length)!)
attributedString?.attribute(NSFontAttributeName: UIFont.fontNames(forFamilyName: "OpenSans-Regular"), at: 1, effectiveRange: &range)

在第二行,我收到一个编译时错误:

Argument labels '(NSFontAttributeName:, at:, effectiveRange:)' do not match any available overloads

最佳答案

你需要:

var range = NSRange(location: 0, length: attributedString?.length)
let font = attributedString?.attribute(NSFontAttributeName, at: 1, effectiveRange: &range)

第一个参数就是您要检查的属性。您不传递特定字体。此方法将告诉您要在指定位置找到字体。

关于ios - NSRangePointer 错误 swift ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39795842/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com