feat:step 4

This commit is contained in:
pengfei.zhou 2019-11-27 16:41:04 +08:00
parent 1dabccbe50
commit 91a26eb9a8
2 changed files with 12 additions and 14 deletions

View File

@ -94,17 +94,8 @@ - (CGSize)measureSize:(CGSize)targetSize {
* layout self and subviews
* */
- (void)layoutSelf:(CGSize)targetSize {
CGSize contentSize = [self sizeThatFits:targetSize];
if (self.layoutConfig.widthSpec == DoricLayoutAtMost) {
self.width = targetSize.width;
} else if (self.layoutConfig.widthSpec == DoricLayoutWrapContent) {
self.width = contentSize.width;
}
if (self.layoutConfig.heightSpec == DoricLayoutAtMost) {
self.height = targetSize.height;
} else if (self.layoutConfig.heightSpec == DoricLayoutWrapContent) {
self.height = contentSize.height;
}
self.width = targetSize.width;
self.height = targetSize.height;
}
- (BOOL)requestSuperview {
@ -167,6 +158,10 @@ @interface DoricLayoutContainer ()
@end
@implementation DoricLayoutContainer
- (void)setNeedsLayout {
[super setNeedsLayout];
}
- (void)layoutSubviews {
[super layoutSubviews];
[self doricLayoutSubviews];
@ -294,8 +289,6 @@ - (CGSize)sizeThatFits:(CGSize)size {
- (void)layoutSelf:(CGSize)targetSize {
[super layoutSelf:targetSize];
self.width = targetSize.width;
self.height = targetSize.height;
CGFloat yStart = 0;
if ((self.gravity & TOP) == TOP) {
yStart = 0;

View File

@ -41,9 +41,14 @@ - (CGSize)sizeThatFits:(CGSize)size {
- (void)layoutSelf:(CGSize)targetSize {
[super layoutSelf:targetSize];
[self.contentView layoutSelf: [self.contentView sizeThatFits:targetSize]];
[self.contentView layoutSelf:[self.contentView sizeThatFits:targetSize]];
[self setContentSize:self.contentView.frame.size];
}
- (CGSize)measureSize:(CGSize)targetSize {
CGSize size = [super measureSize:targetSize];
return CGSizeMake(MIN(targetSize.width, size.width), MIN(targetSize.height, size.height));
}
@end
@interface DoricScrollerNode ()