Closed aderae closed 10 years ago
I need more info to investigate. Can you dig into what is happening exactly, does the frame drops to CGRectZero, does the CTFont you are using still exists in iOS7, are you using Dynamic Type, …?
@AliSoftware
Got the same issue on iOS 7.
It happens when i mix color of letters in one label using attributes
[attrString addAttribute:(NSString*)kCTForegroundColorAttributeName value:(__bridge id)(colorRef) range:range];
@AliSoftware @aderae Ok, furthermore i've got rid of manually adding color attributes myself and from now on i use:
NSMutableAttributedString *mAttributedText = [[NSAttributedString attributedStringWithString:concatenatedText] mutableCopy];
[mAttributedText setTextColor:blackColor range:blackRange];
[mAttributedText setTextColor:grayColor range:grayedRange];
self.attributedText = [[NSAttributedString alloc] initWithAttributedString:mAttributedText];
And it renders just right. But when i try to also alter font size
[mAttributedText setFontName:[self.font familyName] size:self.font.pointSize];
or
[mAttributedText setFont:[UIFont systemFontOfSize:self.font.pointSize]]
my label disappears but it only occurs when running on iOS 7. On iOS 6 everything is ok after all.
What about when you do the same with a standard UILabel
?
What about if you increase the OHAttributedLabel
's frame.size.height
to give more space, especially since the font is bigger? I bet this one let the text be displayed once you give it some space.
As explained multiple times in other issues, Apple's CoreText
text layout engine (CTFrameSetter
) does not render CTLines
(text lines) at all if there is not enough space (as opposed to UIKit
which at least renders the line partially even if we can only see the upper part of the text at the end).
So if you don't have enough height to display the one line of text you have, it won't display at all, not even partially, and you have to increase the label's height so it's high enough for your font size.
You should obviously use NSAttributedString+Attributes
's sizeConstrainedToSize:
method to compute that needed height, or use OHAttributedLabel
's sizeToFit
/sizeThatFits:
methods for the same purpose, that's what those methods are for after all.
@AliSoftware thank you very much! Increasing frame works. From now on i have only one issue. The text in the label is positioned differently between iOS 6 and iOS 7. On iOS 6 the text is 2 points higher. So i had to hardcode the change in order for the label to look the same on both iOS versions.
I heard the baseline of some of the fonts embedded in iOS have changed in iOS7 (to be more accurately aligned), maybe the position of the baseline of the font you are using did offset by 2 pixels between the version of the TTF file in iOS6 and the version of the same TTF in iOS7?
Maybe try a custom font that you provide in your app (at least for the sake of the test) to confirm or infirm if this is due to a difference in the embedded iOS fonts accross iOS versions?
I'm closing this issue (as the original "not displaying" issue is now solved by my solution)
I am using your OHAttributed Label classes.Could you please tell me how can I draw text on a circle(outside/inside) i.e circular text. Thanks in advance
@garora12 That question is not related to the original issue, nor even with OHAttributedLabel that does not support that at all (that is not its purpose, and it won't add it as this pod is deprecated since a long time now, see the README).
Nowadays you would simply use Apple's TextKit for that (but you still need to implement all the logic of placing each character at the right position on the circle), but that's totally out of the scope of my repo, so please ask this kind of question on places more suited for this, like StackOverflow or some dev forums.
Hello,
When I compile my project in ios 6.1.4 SDK and run it on iOS7, my NSLabel's either doesn't show or doesn't go on to the new line.
Can you check ?