iOS:fix Scroller

This commit is contained in:
pengfei.zhou 2020-04-03 18:15:43 +08:00 committed by osborn
parent 2e0bbcfb89
commit eb78e3e201
3 changed files with 29 additions and 24 deletions

View File

@ -95,6 +95,8 @@ typedef NS_ENUM(NSInteger, DoricGravity) {
- (instancetype)init;
- (void)apply;
- (void)apply:(CGSize)frameSize;
@end

View File

@ -69,16 +69,20 @@ - (instancetype)init {
return self;
}
- (void)apply {
- (void)apply:(CGSize)frameSize {
if (!CGAffineTransformEqualToTransform(self.view.transform, CGAffineTransformIdentity)) {
return;
}
self.resolved = NO;
[self measure:self.view.frame.size];
[self measure:frameSize];
[self layout];
[self setFrame];
}
- (void)apply {
[self apply:self.view.frame.size];
}
- (void)measure:(CGSize)targetSize {
if (self.widthSpec == DoricLayoutMost) {
self.measuredWidth = targetSize.width;
@ -433,7 +437,7 @@ - (void)layoutHLayout {
if ((gravity & DoricGravityTop) == DoricGravityTop) {
layout.measuredY = self.paddingTop;
} else if ((gravity & DoricGravityBottom) == DoricGravityBottom) {
layout.measuredY = self.measuredHeight - self.paddingBottom - child.height;
layout.measuredY = self.measuredHeight - self.paddingBottom - layout.measuredHeight;
} else if ((gravity & DoricGravityCenterY) == DoricGravityCenterY) {
layout.measuredY = self.measuredHeight / 2 - layout.measuredHeight / 2;
} else {

View File

@ -27,26 +27,26 @@
@implementation DoricScrollView
//- (void)setContentView:(UIView *)contentView {
// if (_contentView) {
// [_contentView removeFromSuperview];
// }
// _contentView = contentView;
// [self addSubview:contentView];
//}
//
//- (CGSize)sizeThatFits:(CGSize)size {
// if (self.contentView) {
// return [self.contentView measureSize:size];
// }
// return CGSizeZero;
//}
//
//- (void)layoutSelf:(CGSize)targetSize {
// [super layoutSelf:targetSize];
// [self setContentSize:self.contentView.frame.size];
//}
- (void)setContentView:(UIView *)contentView {
if (_contentView) {
[_contentView removeFromSuperview];
}
_contentView = contentView;
[self addSubview:contentView];
}
- (CGSize)sizeThatFits:(CGSize)size {
if (self.contentView) {
[self.contentView.doricLayout apply:self.frame.size];
return self.contentView.frame.size;
}
return CGSizeZero;
}
- (void)layoutSubviews {
[super layoutSubviews];
self.contentSize = self.contentView.frame.size;
}
@end
@interface DoricScrollerNode () <UIScrollViewDelegate>
@ -77,8 +77,7 @@ - (void)initWithSuperNode:(DoricSuperNode *)superNode {
}
}
- (void)blend:(NSDictionary *)props {
[super blend:props];
- (void)afterBlended:(NSDictionary *)props {
NSDictionary *childModel = [self subModelOf:self.childViewId];
if (!childModel) {
return;