boundingRectWithSize:options:attributes:context

本文详细介绍了iOS中用于文本布局的NSStringDrawingOptions选项,包括文本起始原点、行高计算方式、设备度量使用、文本截断及省略处理等,并解释了这些选项在实际应用中的作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

<span style="font-size:18px;"><strong>[_status.text boundingRectWithSize:CGSizeMake(textW, 1000) options:(NSStringDrawingOptions) attributes: context:<#(nullable NSStringDrawingContext *)#>]</strong></span>

<span style="font-size:18px;"><strong>options:


</strong></span>

<span style="font-size:18px;"><strong>NSStringDrawingUsesLineFragmentOrigin = 1 << 0, // The specified origin is the line fragment origin, not the base line origin
    NSStringDrawingUsesFontLeading = 1 << 1, // Uses the font leading for calculating line heights
    NSStringDrawingUsesDeviceMetrics = 1 << 3, // Uses image glyph bounds instead of typographic bounds
    NSStringDrawingTruncatesLastVisibleLine NS_ENUM_AVAILABLE(10_5, 6_0) = 1 << 5, // Truncates and adds the ellipsis character to the last visible line if the text doesn't fit into the bounds specified. Ignored if NSStringDrawingUsesLineFragmentOrigin is not also set.</strong></span>

<span style="font-size:18px;"><strong>NSStringDrawingUsesLineFragmentOrigin  : 整个文本将以每行组成的矩形为单位计算整个文本的尺寸

</strong></span><pre name="code" class="objc"><span style="font-size:18px;"><strong>NSStringDrawingUsesFontLeading : 以字体间的行距(leading,<span style="font-family:arial,宋体,sans-serif;line-height:24px">行距:从一行文字的底部到另一行文字底部的间距。</span>)来计算。<a target=_blank target="_blank" href="http://shop111849857.taobao.com/shop/view_shop.htm?spm=a1z0e.1.10010.4.Dadm77">字体大小+行间距=行距</a></strong></span><span style="font-size:18px;"><strong>


</strong></span><pre name="code" class="objc"><span style="font-size:18px;"><strong>NSStringDrawingUsesDeviceMetrics  : 计算布局的时候使用的是图形符号计算的,并不是印刷体

</strong></span><pre name="code" class="objc"><span style="font-size:18px;"><strong>NSStringDrawingTruncatesLastVisibleLine : </strong></span><span style="font-size:18px;"><strong>如果文本内容超出指定的矩形限制,文本将被截去并在最后一个字符后加上省略号</strong></span>


<span style="font-size:18px;"><strong>attributes :字体属性  @{NSFontAttributeName:TIME_FONT}

context : context上下文。包括一些信息,例如如何调整字间距以及缩放。最终,该对象包含的信息将用于文本绘制,一贯作风,不知道并且查不出来的时候就写  nil<img alt="大笑" src="http://static.blog.youkuaiyun.com/xheditor/xheditor_emot/default/laugh.gif" />
</strong></span>




评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值