我怎样才能垂直居中使用不同字体的SAttributedString中的一行?(How can I vertically center a line in an SAttributedString with different fonts?)
我有一个SAttributedString这是一个“表”,使用STextTab停止,其中第一列是KEY ,第二列是值
喜欢这个:
| **KEY 1**|value1| |**KEY TWO**|value2|KEYS的字体是不同的大小/重量+全部大写。 行对齐,以便所有字母的底部相匹配。 我想垂直移动这些值,以使它们看起来与KEYS垂直居中。
有没有办法做到这一点? 这看起来高度专业化,但从设计角度来看,我认为它会更好
I have a SAttributedString which is a "table" using STextTab stops where the first column is the KEY and the second column is the value
Like this:
| **KEY 1**|value1| |**KEY TWO**|value2|The font for the KEYS is different size/weight + it is all caps. The rows align so that the bottoms of all the letters match up. I would like to nudge the values up vertically so that they appear to be vertically centered with the KEYS.
Is there any way to do this? This seems highly specialized, but from a design perspective I think it will look much better
最满意答案
我没有尝试过,但它似乎应该能够使用SBaselineOffsetAttributeame这个。 以下是文档对此的评论:
此属性的值是一个Sumber对象,其中包含一个浮点值,指示该角与基线的偏移量,以点为单位。 默认值是0。
所以你可能需要计算移动这些值所需的点数 - 我猜这只是键和值之间字体大小差异的一半。 然后将SBaselineOffsetAttributeame与该数量的点一起应用于值的文本。
I haven't tried it, but it seems like you should be able to use SBaselineOffsetAttributeame for this. Here's what the docs say about it:
The value of this attribute is an Sumber object containing a floating point value indicating the character’s offset from the baseline, in points. The default value is 0.
So you'll probably have to compute the number of points needed to move the values up -- I guess that'd be half the difference in font sizes between the keys and values. Then apply SBaselineOffsetAttributeame with that number of points to the text for the values.
#感谢您对电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格的认可,转载请说明来源于"电脑配置推荐网 - 最新i3 i5 i7组装电脑配置单推荐报价格
下一篇:前端工作一年半,离职了!!!
推荐阅读
留言与评论(共有 18 条评论) |
本站网友 装修墙纸图片 | 16分钟前 发表 |
我认为它会更好 I have a SAttributedString which is a "table" using STextTab stops where the first column is the KEY and the second column is the value Like this | |
本站网友 武汉青春痘医院 | 25分钟前 发表 |
but from a design perspective I think it will look much better 最满意答案 我没有尝试过 | |
本站网友 创业板规则 | 5分钟前 发表 |
然后将SBaselineOffsetAttributeame与该数量的点一起应用于值的文本 | |
本站网友 河南癫痫病医院哪家好 | 28分钟前 发表 |
我想垂直移动这些值 | |
本站网友 怎么减肥啊 | 14分钟前 发表 |
The value of this attribute is an Sumber object containing a floating point value indicating the character’s offset from the baseline | |
本站网友 怎样治脚气偏方 | 15分钟前 发表 |
指示该角与基线的偏移量 | |
本站网友 李玫 | 15分钟前 发表 |
所以你可能需要计算移动这些值所需的点数 - 我猜这只是键和值之间字体大小差异的一半 | |
本站网友 游艺设备 | 2分钟前 发表 |
我想垂直移动这些值 | |
本站网友 玉米须的作用 | 1分钟前 发表 |
The value of this attribute is an Sumber object containing a floating point value indicating the character’s offset from the baseline | |
本站网友 性之道 | 18分钟前 发表 |
其中包含一个浮点值 | |
本站网友 专治痤疮 | 5分钟前 发表 |
以使它们看起来与KEYS垂直居中 | |
本站网友 邱学军 | 3分钟前 发表 |
但从设计角度来看 | |
本站网友 痦子 | 23分钟前 发表 |
but from a design perspective I think it will look much better 最满意答案 我没有尝试过 | |
本站网友 怎么除去青春痘 | 23分钟前 发表 |
我想垂直移动这些值 | |
本站网友 星汇园 | 11分钟前 发表 |
其中包含一个浮点值 | |
本站网友 sjyy | 23分钟前 发表 |
but from a design perspective I think it will look much better 最满意答案 我没有尝试过 | |
本站网友 西安信息 | 1分钟前 发表 |
我认为它会更好 I have a SAttributedString which is a "table" using STextTab stops where the first column is the KEY and the second column is the value Like this |