菜鸟教程小白 发表于 2022-12-12 15:23:46

iphone - 是否有 iOS 7 中文本和字符串绘制系统更改的概述?


                                            <p><p><strong>在 iOS 7 中,一些最重要的字符串绘制和度量计算方法是 <a href="https://developer.apple.com/library/ios/documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html" rel="noreferrer noopener nofollow">depracated</a>没有明显的替代方案。</strong></p>

<p> <img src="/image/59XJ6.jpg" alt="enter image description here"/> </p>

<p><a href="https://developer.apple.com/library/ios/documentation/uikit/reference/NSString_UIKit_Additions/Reference/Reference.html" rel="noreferrer noopener nofollow">NSString UIKit Additions Reference</a> 上的页面像血一样红。几乎所有东西都被弃用了。 Xcode 向我抛出 300 条警告。</p>

<p>我试图找出 Apple 的想法以及它们在 UIKit 文本系统中的变化,但我该从哪里开始呢?他们是否在某个地方提到了为什么所有这些都被弃用以及文本系统现在的工作方式有何不同?以及如何适应?当标签可以缩放字体以适应大小时如何计算文本边界框? TextKit 是解决方案吗?</p>

<p>我在 Google 上花了 3 个小时,但没有找到有关如何解决此问题的有用信息。</p>

<p>我们应该在此处记录所有替代方案,以便所有遇到这种令人沮丧的弃用困惑的开发人员都能迅速找到安心。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>如果您查看弃用,其中大多数弃用 <code>UIFont</code> 来使用属性字典。 </p>

<blockquote>
<p>drawInRect:withFont: (Deprecated in iOS 7.0. Use drawInRect:withAttributes: instead.)
drawInRect:withFont:lineBreakMode: (Deprecated in iOS 7.0. Use drawInRect:withAttributes: instead.)<br/>
sizeWithFont:(Deprecated in iOS 7.0. Use sizeWithAttributes: instead.)
etc…</p>
</blockquote>

<p>因此,如果您正在寻找一个起点,请学习如何使用属性字典来设置字体。它看起来有很多弃用,但实际上你不需要学习那么多新东西。</p>

<p>如果您想更新代码以使用新的 TextKit 系统,请查看 WWDC 视频和 <a href="https://developer.apple.com/library/ios/documentation/StringsTextFonts/Conceptual/TextAndWebiPhoneOS/CustomTextProcessing/CustomTextProcessing.html" rel="noreferrer noopener nofollow">TextKit Programming Guide</a> .</p>

<p>如果你想知道 Apple 如此弃用的原因,我猜这与 <code>UILabel</code> 和 <code>UITextView</code> 过去是如何构建在 webView 上的有关,现在它们是基于 TextKit 构建的。</p></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 是否有 iOS 7 中文本和字符串绘制系统更改的概述?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/19196802/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/19196802/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 是否有 iOS 7 中文本和字符串绘制系统更改的概述?