I have a UITableViewCell
with three labels:
The right UILabel
uses its attributedString property to add the subscripts and superscripts for the chemical formula. I am using PureLayout
to set up all autolayout constraints and added the same constraint for the top two labels to manage the distance to the top of the superView (contentView
):
[label autoPinEdgeToSuperviewEdge: ALEdgeTop withInset: 8.0f];
I am also using a constraint to set the distance between the top of the bottom label and the bottom of the left label.
However, as you can see they don't have the same distance to the top, and they are not aligned horizontally. I'm guessing this is because of the super- and/or subscript attributes.
I've also tried aligning their horizontal axes:
[rightLabel autoAlignAxis: ALAxisHorizontal toSameAxisOfView: leftLabel];
But with the same result.
Any suggestions how I can make this work?
EDIT: This seems to be related to this bug: iOS 10.3: NSStrikethroughStyleAttributeName is not rendered if applied to a sub range of NSMutableAttributedString, and only happens in iOS 10.3. If I add the accepted answer from that question, the alignment is as expected.
EDIT: These are the attributes for the right label:
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;
}