mirror of
https://github.com/HackPlan/AsyncDisplayKit.git
synced 2026-05-12 16:23:08 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user