|
@@ -388,6 +388,8 @@ dispatch_semaphore_signal(_lock);
|
|
|
NSUInteger *lineRowsIndex = NULL;
|
|
|
NSRange visibleRange;
|
|
|
NSUInteger maximumNumberOfRows = 0;
|
|
|
+ BOOL constraintSizeIsExtended = NO;
|
|
|
+ CGRect constraintRectBeforeExtended = {0};
|
|
|
|
|
|
text = text.mutableCopy;
|
|
|
container = container.copy;
|
|
@@ -399,12 +401,18 @@ dispatch_semaphore_signal(_lock);
|
|
|
// CoreText bug when draw joined emoji since iOS 8.3.
|
|
|
// See -[NSMutableAttributedString setClearColorToJoinedEmoji] for more information.
|
|
|
static BOOL needFixJoinedEmojiBug = NO;
|
|
|
+ // It may use larger constraint size when create CTFrame with
|
|
|
+ // CTFramesetterCreateFrame in iOS 10.
|
|
|
+ static BOOL needFixLayoutSizeBug = NO;
|
|
|
static dispatch_once_t onceToken;
|
|
|
dispatch_once(&onceToken, ^{
|
|
|
double systemVersionDouble = [UIDevice currentDevice].systemVersion.doubleValue;
|
|
|
if (8.3 <= systemVersionDouble && systemVersionDouble < 9) {
|
|
|
needFixJoinedEmojiBug = YES;
|
|
|
}
|
|
|
+ if (systemVersionDouble >= 10) {
|
|
|
+ needFixLayoutSizeBug = YES;
|
|
|
+ }
|
|
|
});
|
|
|
if (needFixJoinedEmojiBug) {
|
|
|
[((NSMutableAttributedString *)text) yy_setClearColorToJoinedEmoji];
|
|
@@ -420,6 +428,16 @@ dispatch_semaphore_signal(_lock);
|
|
|
if (container.path == nil && container.exclusionPaths.count == 0) {
|
|
|
if (container.size.width <= 0 || container.size.height <= 0) goto fail;
|
|
|
CGRect rect = (CGRect) {CGPointZero, container.size };
|
|
|
+ if (needFixLayoutSizeBug) {
|
|
|
+ constraintSizeIsExtended = YES;
|
|
|
+ constraintRectBeforeExtended = UIEdgeInsetsInsetRect(rect, container.insets);
|
|
|
+ constraintRectBeforeExtended = CGRectStandardize(constraintRectBeforeExtended);
|
|
|
+ if (container.isVerticalForm) {
|
|
|
+ rect.size.width = YYTextContainerMaxSize.width;
|
|
|
+ } else {
|
|
|
+ rect.size.height = YYTextContainerMaxSize.height;
|
|
|
+ }
|
|
|
+ }
|
|
|
rect = UIEdgeInsetsInsetRect(rect, container.insets);
|
|
|
rect = CGRectStandardize(rect);
|
|
|
cgPathBox = rect;
|
|
@@ -511,6 +529,19 @@ dispatch_semaphore_signal(_lock);
|
|
|
|
|
|
YYTextLine *line = [YYTextLine lineWithCTLine:ctLine position:position vertical:isVerticalForm];
|
|
|
CGRect rect = line.bounds;
|
|
|
+
|
|
|
+ if (constraintSizeIsExtended) {
|
|
|
+ if (isVerticalForm) {
|
|
|
+ if (rect.origin.x + rect.size.width >
|
|
|
+ constraintRectBeforeExtended.origin.x +
|
|
|
+ constraintRectBeforeExtended.size.width) break;
|
|
|
+ } else {
|
|
|
+ if (rect.origin.y + rect.size.height >
|
|
|
+ constraintRectBeforeExtended.origin.y +
|
|
|
+ constraintRectBeforeExtended.size.height) break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
BOOL newRow = YES;
|
|
|
if (rowMaySeparated && position.x != lastPosition.x) {
|
|
|
if (isVerticalForm) {
|