ios - 当 pointSize 为 0 时,UIFont 没有设置正确的字体名称
<p><p>为什么UIFont在大小设置为零时会错误地打印出字体名称?
当我将大小设置为大于零的任何值时,就会输出正确的字体名称。这种行为背后是否有特殊原因,或者这是一个真正的错误。</p>
<pre><code>UIFont* f1 = ;
NSLog(@"%@",f1);
UIFont* f2 = ;
NSLog(@"%@",f2);
</code></pre>
<p>输出:</p>
<pre><code><UICTFont: 0x7fb90c988e10> font-family: "Helvetica"; font-weight: normal; font-style: normal; font-size: 0.00pt
<UICTFont: 0x7fad92177a90> font-family: "HelveticaNeue-Thin"; font-weight: normal; font-style: normal; font-size: 1.00pt
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>在 <a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIFont_Class/index.html#//apple_ref/occ/clm/UIFont/fontWithName:size:" rel="noreferrer noopener nofollow">the documentation</a> :</p>
<blockquote>
<p><em>fontSize</em>The size (in points) to which the font is scaled. This value must be greater than 0.0.</p>
</blockquote>
<p>您正在尝试实现不受支持的行为。预期会出现“不正确”的结果。</p></p>
<p style="font-size: 20px;">关于ios - 当 pointSize 为 0 时,UIFont 没有设置正确的字体名称,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/30533806/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/30533806/
</a>
</p>
页:
[1]