我有一个UITableViewCell
有三个标签:对齐的UILabel与NSSuperscriptAttributeName和自动布局
UILabel
使用其attributedString属性添加上下标对化学式的权利。我使用PureLayout
设置所有自动布局的限制,并添加了相同的约束的前两名标签管理对上海华顶(contentView
)的距离:
[label autoPinEdgeToSuperviewEdge: ALEdgeTop withInset: 8.0f];
我也使用约束来设置底部标签顶部与左侧标签底部之间的距离。
但是,正如您所看到的,它们与顶部没有相同的距离,并且它们没有水平对齐。我猜这是因为超级和/或下标属性。
我也试着调整其水平轴:
[rightLabel autoAlignAxis: ALAxisHorizontal toSameAxisOfView: leftLabel];
但与相同的结果。
任何建议如何使这项工作?
编辑:这似乎与此错误有关:iOS 10.3: NSStrikethroughStyleAttributeName is not rendered if applied to a sub range of NSMutableAttributedString,并且只发生在iOS 10.3中。如果我从这个问题中增加接受的答案,那么这种联系就像预期的那样。
编辑:这些都是正确的标签属性:
CH{
NSBaselineOffset = 1;
NSFont = "<UICTFont: 0x7fcdc2515a10> font-family: \"Avenir-Medium\"; font-weight: normal; font-style: normal; font-size: 17.00pt";
}3{
NSBaselineOffset = 1;
NSFont = "<UICTFont: 0x7fcdc27577e0> font-family: \"Avenir-Medium\"; font-weight: normal; font-style: normal; font-size: 12.75pt";
NSSuperScript = "-1";
}CH{
NSBaselineOffset = 1;
NSFont = "<UICTFont: 0x7fcdc2515a10> font-family: \"Avenir-Medium\"; font-weight: normal; font-style: normal; font-size: 17.00pt";
}2{
NSBaselineOffset = 1;
NSFont = "<UICTFont: 0x7fcdc27577e0> font-family: \"Avenir-Medium\"; font-weight: normal; font-style: normal; font-size: 12.75pt";
NSSuperScript = "-1";
}OH{
NSBaselineOffset = 1;
NSFont = "<UICTFont: 0x7fcdc2515a10> font-family: \"Avenir-Medium\"; font-weight: normal; font-style: normal; font-size: 17.00pt";
}+{
NSBaselineOffset = 1;
NSFont = "<UICTFont: 0x7fcdc27577e0> font-family: \"Avenir-Medium\"; font-weight: normal; font-style: normal; font-size: 12.75pt";
NSSuperScript = 1;
}
我会试一试,谢谢指出。 – Koen