gpt4 book ai didi

ios - 在 iOS 15 中,在 UILabel 中使用 unicode 字符时,软连字符无法正常工作

转载 作者:行者123 更新时间:2023-12-05 00:23:12 24 4
gpt4 key购买 nike

在 iOS 15 中,在 UILabel 上设置文本时不考虑软连字符 ( \u{00AD} ) .例如:以下代码确实在 iOS 13 和 14 中正确呈现了带有软连字符的文本,但在 iOS 15 中却没有。

import UIKit

class ViewController: UIViewController {

@IBOutlet weak var label: UILabel!

override func viewDidLoad() {
super.viewDidLoad()
label.text = "Very\u{00AD}VeryVeryVeryVeryVeryLongWordWithASoftHyphenTo"
}
}
结果:
enter image description here
如何让 UILabel 考虑 iOS 15 中的软连字符( \u{00AD} )?

最佳答案

得到苹果对此的回应:

Before iOS 15, we strictly followed soft hyphen, while in iOS 15 wenow only consider those as hyphenation opportunities.

That is the design, and there are no plans to change it. The appshould be able to use languageIdentifier attribute to influence thehyphenation with the attributed string so that it should follow Germanhyphenation even when system language is English.

https://developer.apple.com/documentation/foundation/attributescopes/foundationattributes/3802173-languageidentifier


所以基本上现在我们应该使用 languageIdentifier 属性,我们自己的自定义断字规则的机会更少(比如删除丑陋,一侧短,断字断字),但在语法上正确工作。
软连字符仍然有效,但只是作为补充。

关于ios - 在 iOS 15 中,在 UILabel 中使用 unicode 字符时,软连字符无法正常工作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69312990/

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