Workaround iOS 7 text drawing bug (#2492)

This commit is contained in:
Adlai Holler
2016-10-27 11:48:49 -07:00
committed by GitHub
parent eb6cf0689d
commit c0125010c1

View File

@@ -265,7 +265,12 @@ static NSCharacterSet *_defaultAvoidTruncationCharacterSet()
// If we use default options, we can use NSAttributedString for a
// fast path.
if (self.canUseFastPath) {
[_attributes.attributedString drawWithRect:shadowInsetBounds options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine context:self.stringDrawingContext];
CGRect drawingBounds = shadowInsetBounds;
// Add a fudge-factor to the height, to workaround a bug in iOS 7
if (AS_AT_LEAST_IOS8 == NO) {
drawingBounds.size.height += 3;
}
[_attributes.attributedString drawWithRect:drawingBounds options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingTruncatesLastVisibleLine context:self.stringDrawingContext];
} else {
BOOL isScaled = [self isScaled];
[[self context] performBlockWithLockedTextKitComponents:^(NSLayoutManager *layoutManager, NSTextStorage *textStorage, NSTextContainer *textContainer) {