ios - 两个具有不同字体大小的自动布局 UILabel : Text Top alignment
<p><p>有没有办法设置两个 UILabel 文本顶部对齐?两者都是不同的字体大小。 <a href="/image/RRIfK.png" rel="noreferrer noopener nofollow"><img src="/image/RRIfK.png" alt="enter image description here"/></a> </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我可以给你看一张这张图片的例子:</p>
<p> <a href="/image/Xsxa2.png" rel="noreferrer noopener nofollow"><img src="/image/Xsxa2.png" alt="enter image description here"/></a> </p>
<p>代码:</p>
<pre><code>- (NSMutableAttributedString *)styleSalePriceLabel:(NSString *)salePrice withFont:(UIFont *)font
{
if (.location == NSNotFound) {
return [ initWithString:salePrice];
} else {
NSRange range = ;
range.length = (salePrice.length - range.location);
NSMutableAttributedString *stylizedPriceLabel = [ initWithString:salePrice];
UIFont *smallFont = ;
NSNumber *offsetAmount = @(font.capHeight - smallFont.capHeight);
;
;
return stylizedPriceLabel;
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - 两个具有不同字体大小的自动布局 UILabel : Text Top alignment,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/38863255/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/38863255/
</a>
</p>
页:
[1]