由NSStringDrawingOptions项目含义混淆 [英] Confused by NSStringDrawingOptions item meaning

查看:775
本文介绍了由NSStringDrawingOptions项目含义混淆的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

iOS7及更高版本,我们可以使用 - (void)drawWithRect:(CGRect)rect选项:(NSStringDrawingOptions)选项属性:(NSDictionary *)属性context:(NSStringDrawingContext *)context 计算字符串大小,但我对 NSStringDrawingOptions enum上的注释感到困惑。

iOS7 and later, we can use - (void)drawWithRect:(CGRect)rect options:(NSStringDrawingOptions)options attributes:(NSDictionary *)attributes context:(NSStringDrawingContext *)context to calculate the string size, but I'm confused with the comments on NSStringDrawingOptions enum.

NSStringDrawingUsesLineFragmentOrigin

NSStringDrawingUsesLineFragmentOrigin

这意味着指定的原点是线段原点,而不是基线原点。但是线段片段起源和基线原点的含义是什么。

It means specified origin is the line fragment origin, not the base line origin. But what mean of line fragment origin and baseline origin.

就像WWDC 2013会话220(高级文本布局和带文本工具包的效果)PDF页面95.

Just like the WWDC 2013 Session 220 (Advanced Text Layouts and Effects with Text Kit) PDF on Page 95.

如果线段碎片起源是指蓝点,那么基线来源是什么?

If line fragment origin mean the blue dot, what the baseline origin?

推荐答案

来自官方文档


讨论

如果在$中指定 NSStringDrawingUsesLineFragmentOrigin b $ b选项,它根据需要包装字符串文本以使其适合。如果
字符串太大而无法完全适合矩形,则方法
会缩放字体或调整字母间距以使字符串在给定范围内适合

If NSStringDrawingUsesLineFragmentOrigin is specified in options, it wraps the string text as needed to make it fit. If the string is too big to fit completely inside the rectangle, the method scales the font or adjusts the letter spacing to make the string fit within the given bounds.

如果未在选项中指定 NSStringDrawingUsesLineFragmentOrigin ,则
矩形的原点是唯一线的基线。文本
将显示在矩形上方而不是内部。对于
示例,如果指定一个从0,0开始的矩形并绘制
字符串'juxtaposed',则只有'j'和'p'的下降部分将是
。文本的其余部分将位于矩形的上边缘。

If NSStringDrawingUsesLineFragmentOrigin is not specified in options, the origin of the rectangle is the baseline of the only line. The text will be displayed above the rectangle and not inside of it. For example, if you specify a rectangle starting at 0,0 and draw the string ‘juxtaposed’, only the descenders of the ‘j’ and ‘p’ will be seen. The rest of the text will be on the top edge of the rectangle.

此方法使用
属性字符串本身中指定的属性绘制线条。如果
字符串中存在换行符,则会对这些字符进行处理,并使后续文本在起始点下面的下一行放置

This method draws the line using the attributes specified in the attributed string itself. If newline characters are present in the string, those characters are honored and cause subsequent text to be placed on the next line underneath the starting point.

特殊注意事项此方法使用默认的
基线原点,因此它将字符串呈现为单行。要在多行中呈现
字符串,请在选项中指定
NSStringDrawingUsesLineFragmentOrigin。

Special Considerations This method uses the baseline origin by default, so it renders the string as a single line. To render the string in multiple lines, specify NSStringDrawingUsesLineFragmentOrigin in options.

这篇关于由NSStringDrawingOptions项目含义混淆的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆