ASTextNode expose exclusion paths

expose NSTextContainer's exclusionPaths property on ASTextNode to be able to exclude view areas from typesetting.

This implements #394
This commit is contained in:
Tobias Klonk
2015-04-20 10:21:01 +02:00
parent 1316389f10
commit 2a29f81b3a
6 changed files with 81 additions and 0 deletions

View File

@@ -22,6 +22,7 @@
@property (nonatomic, readwrite, assign) CGFloat lineSpacing;
@property (nonatomic, readwrite, assign) CGSize constrainedSize;
@property (nonatomic, readwrite) NSArray *exclusionPaths;
@end
@@ -43,6 +44,8 @@
_attributedString = [[NSAttributedString alloc] initWithString:@"Lorem ipsum" attributes:attributes];
_truncationString = [[NSAttributedString alloc] initWithString:@"More"];
_exclusionPaths = nil;
_constrainedSize = CGSizeMake(FLT_MAX, FLT_MAX);
}
@@ -52,6 +55,7 @@
truncationString:_truncationString
truncationMode:_truncationMode
maximumLineCount:_maximumLineCount
exclusionPaths:_exclusionPaths
constrainedSize:_constrainedSize];
}
@@ -141,4 +145,18 @@
}];
}
- (void)testExclusionPaths
{
_constrainedSize = CGSizeMake(200, CGFLOAT_MAX);
[self setUpRenderer];
CGSize sizeWithoutExclusionPath = [_renderer size];
CGRect exclusionRect = CGRectMake(20, 0, 180, _lineSpacing * 2.0);
_exclusionPaths = @[[UIBezierPath bezierPathWithRect:exclusionRect]];
[self setUpRenderer];
CGSize sizeWithExclusionPath = [_renderer size];
XCTAssertEqualWithAccuracy(sizeWithoutExclusionPath.height + exclusionRect.size.height, sizeWithExclusionPath.height, 0.5, @"Using an exclusion path so the the text can not fit into the first two lines should increment the size of the text by the heigth of the exclusion path");
}
@end