iOS:TextNode use content size
This commit is contained in:
parent
88c594ae10
commit
228c2c131c
@ -105,6 +105,9 @@ typedef NS_ENUM(NSInteger, DoricGravity) {
|
||||
|
||||
@property(nonatomic, assign) UIEdgeInsets corners;
|
||||
|
||||
@property(nonatomic, assign) CGFloat contentWidth;
|
||||
|
||||
@property(nonatomic, assign) CGFloat contentHeight;
|
||||
- (instancetype)init;
|
||||
|
||||
- (void)measure:(CGSize)targetSize;
|
||||
|
@ -83,8 +83,6 @@ - (DoricLayout *)doricLayout {
|
||||
@end
|
||||
|
||||
@interface DoricLayout ()
|
||||
@property(nonatomic, assign) CGFloat contentWidth;
|
||||
@property(nonatomic, assign) CGFloat contentHeight;
|
||||
@end
|
||||
|
||||
@implementation DoricLayout
|
||||
|
@ -39,19 +39,19 @@ - (void)drawTextInRect:(CGRect)rect {
|
||||
self.doricLayout.paddingBottom,
|
||||
self.doricLayout.paddingRight));
|
||||
if ((self.gravity & DoricGravityTop) == DoricGravityTop) {
|
||||
CGRect realRect = [self textRectForBounds:rect
|
||||
limitedToNumberOfLines:self.numberOfLines];
|
||||
rect.origin.y = self.doricLayout.paddingTop;
|
||||
rect.size.height = realRect.size.height;
|
||||
rect.size.height = self.doricLayout.contentHeight;
|
||||
} else if ((self.gravity & DoricGravityBottom) == DoricGravityBottom) {
|
||||
CGRect realRect = [self textRectForBounds:rect
|
||||
limitedToNumberOfLines:self.numberOfLines];
|
||||
rect.origin.y = self.height - realRect.size.height - self.doricLayout.paddingBottom;
|
||||
rect.size.height = realRect.size.height;
|
||||
rect.origin.y = self.height - self.doricLayout.contentHeight - self.doricLayout.paddingBottom;
|
||||
rect.size.height = self.doricLayout.contentHeight;
|
||||
}
|
||||
rect.size.width = MAX(0.01f,rect.size.width);
|
||||
rect.size.width = MAX(0.01f, rect.size.width);
|
||||
[super drawTextInRect:rect];
|
||||
}
|
||||
|
||||
- (CGSize)sizeThatFits:(CGSize)size {
|
||||
return [super sizeThatFits:size];
|
||||
}
|
||||
@end
|
||||
|
||||
@interface DoricTextNode ()
|
||||
|
Reference in New Issue
Block a user