0

我有一个UITableViewCell带有三个标签的:

在此处输入图像描述

右侧UILabel使用其属性字符串属性添加化学式的下标和上标。我正在使用PureLayout设置所有自动布局约束并为前两个标签添加相同的约束以管理到 superView ( contentView) 顶部的距离:

[label autoPinEdgeToSuperviewEdge: ALEdgeTop withInset: 8.0f];

我还使用约束来设置底部标签顶部和左侧标签底部之间的距离。

但是,如您所见,它们与顶部的距离不同,并且它们没有水平对齐。我猜这是因为上标和/或下标属性。

我也尝试过对齐它们的水平轴:

[rightLabel autoAlignAxis: ALAxisHorizontal toSameAxisOfView: leftLabel];

但结果相同。

有什么建议可以让我完成这项工作吗?

编辑:这似乎与此错误有关:iOS 10.3: NSStrikethroughStyleAttributeName 如果应用于 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;
}
4

1 回答 1

0

您可以尝试将 UIStackview 用于对齐 = .center 的两个顶部标签,或者仅使用匹配的插图固定右标签。排版很难

于 2017-04-22T20:10:33.040 回答