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) UIEdgeInsets corners;
|
||||||
|
|
||||||
|
@property(nonatomic, assign) CGFloat contentWidth;
|
||||||
|
|
||||||
|
@property(nonatomic, assign) CGFloat contentHeight;
|
||||||
- (instancetype)init;
|
- (instancetype)init;
|
||||||
|
|
||||||
- (void)measure:(CGSize)targetSize;
|
- (void)measure:(CGSize)targetSize;
|
||||||
|
@ -83,8 +83,6 @@ - (DoricLayout *)doricLayout {
|
|||||||
@end
|
@end
|
||||||
|
|
||||||
@interface DoricLayout ()
|
@interface DoricLayout ()
|
||||||
@property(nonatomic, assign) CGFloat contentWidth;
|
|
||||||
@property(nonatomic, assign) CGFloat contentHeight;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricLayout
|
@implementation DoricLayout
|
||||||
|
@ -39,19 +39,19 @@ - (void)drawTextInRect:(CGRect)rect {
|
|||||||
self.doricLayout.paddingBottom,
|
self.doricLayout.paddingBottom,
|
||||||
self.doricLayout.paddingRight));
|
self.doricLayout.paddingRight));
|
||||||
if ((self.gravity & DoricGravityTop) == DoricGravityTop) {
|
if ((self.gravity & DoricGravityTop) == DoricGravityTop) {
|
||||||
CGRect realRect = [self textRectForBounds:rect
|
|
||||||
limitedToNumberOfLines:self.numberOfLines];
|
|
||||||
rect.origin.y = self.doricLayout.paddingTop;
|
rect.origin.y = self.doricLayout.paddingTop;
|
||||||
rect.size.height = realRect.size.height;
|
rect.size.height = self.doricLayout.contentHeight;
|
||||||
} else if ((self.gravity & DoricGravityBottom) == DoricGravityBottom) {
|
} else if ((self.gravity & DoricGravityBottom) == DoricGravityBottom) {
|
||||||
CGRect realRect = [self textRectForBounds:rect
|
rect.origin.y = self.height - self.doricLayout.contentHeight - self.doricLayout.paddingBottom;
|
||||||
limitedToNumberOfLines:self.numberOfLines];
|
rect.size.height = self.doricLayout.contentHeight;
|
||||||
rect.origin.y = self.height - realRect.size.height - self.doricLayout.paddingBottom;
|
|
||||||
rect.size.height = realRect.size.height;
|
|
||||||
}
|
}
|
||||||
rect.size.width = MAX(0.01f, rect.size.width);
|
rect.size.width = MAX(0.01f, rect.size.width);
|
||||||
[super drawTextInRect:rect];
|
[super drawTextInRect:rect];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
- (CGSize)sizeThatFits:(CGSize)size {
|
||||||
|
return [super sizeThatFits:size];
|
||||||
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@interface DoricTextNode ()
|
@interface DoricTextNode ()
|
||||||
|
Reference in New Issue
Block a user