iOS:keep iOS behavior align to android
This commit is contained in:
parent
fb23a11aa9
commit
89333e2252
@ -27,7 +27,7 @@ @interface DoricFlexView : UIView
|
|||||||
|
|
||||||
@implementation DoricFlexView
|
@implementation DoricFlexView
|
||||||
- (CGSize)sizeThatFits:(CGSize)size {
|
- (CGSize)sizeThatFits:(CGSize)size {
|
||||||
return [self.yoga calculateLayoutWithSize:size];
|
return [self.yoga intrinsicSize];
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@ -195,8 +195,33 @@ - (YGValue)translateYGValueFromProperty:(id)prop {
|
|||||||
- (void)requestLayout {
|
- (void)requestLayout {
|
||||||
[super requestLayout];
|
[super requestLayout];
|
||||||
for (UIView *view in self.view.subviews) {
|
for (UIView *view in self.view.subviews) {
|
||||||
|
if ([view isKindOfClass:[DoricFlexView class]]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
[view.doricLayout apply];
|
||||||
|
}
|
||||||
|
if (self.view.doricLayout.widthSpec != DoricLayoutFit) {
|
||||||
|
self.view.yoga.width = YGPointValue(self.view.width);
|
||||||
|
}
|
||||||
|
if (self.view.doricLayout.heightSpec != DoricLayoutFit) {
|
||||||
|
self.view.yoga.height = YGPointValue(self.view.height);
|
||||||
|
}
|
||||||
|
[self.view.yoga applyLayoutPreservingOrigin:YES];
|
||||||
|
/// Need layout again.
|
||||||
|
for (UIView *view in self.view.subviews) {
|
||||||
|
if ([view isKindOfClass:[DoricFlexView class]]) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (view.doricLayout.measuredWidth == view.width && view.doricLayout.measuredHeight == view.height) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
view.doricLayout.widthSpec = DoricLayoutJust;
|
||||||
|
view.doricLayout.heightSpec = DoricLayoutJust;
|
||||||
|
view.doricLayout.width = view.width;
|
||||||
|
view.doricLayout.height = view.height;
|
||||||
|
view.doricLayout.measuredX = view.left;
|
||||||
|
view.doricLayout.measuredY = view.top;
|
||||||
[view.doricLayout apply];
|
[view.doricLayout apply];
|
||||||
}
|
}
|
||||||
[self.view.yoga applyLayoutPreservingOrigin:NO];
|
|
||||||
}
|
}
|
||||||
@end
|
@end
|
||||||
|
@ -92,6 +92,11 @@ typedef NS_ENUM(NSInteger, DoricGravity) {
|
|||||||
|
|
||||||
@property(nonatomic, assign) BOOL resolved;
|
@property(nonatomic, assign) BOOL resolved;
|
||||||
|
|
||||||
|
@property(nonatomic, assign) CGFloat measuredWidth;
|
||||||
|
@property(nonatomic, assign) CGFloat measuredHeight;
|
||||||
|
@property(nonatomic, assign) CGFloat measuredX;
|
||||||
|
@property(nonatomic, assign) CGFloat measuredY;
|
||||||
|
|
||||||
- (instancetype)init;
|
- (instancetype)init;
|
||||||
|
|
||||||
- (void)apply;
|
- (void)apply;
|
||||||
|
@ -48,11 +48,6 @@ - (DoricLayout *)doricLayout {
|
|||||||
@interface DoricLayout ()
|
@interface DoricLayout ()
|
||||||
@property(nonatomic, assign) CGFloat contentWidth;
|
@property(nonatomic, assign) CGFloat contentWidth;
|
||||||
@property(nonatomic, assign) CGFloat contentHeight;
|
@property(nonatomic, assign) CGFloat contentHeight;
|
||||||
@property(nonatomic, assign) CGFloat measuredWidth;
|
|
||||||
|
|
||||||
@property(nonatomic, assign) CGFloat measuredHeight;
|
|
||||||
@property(nonatomic, assign) CGFloat measuredX;
|
|
||||||
@property(nonatomic, assign) CGFloat measuredY;
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
@implementation DoricLayout
|
@implementation DoricLayout
|
||||||
|
Reference in New Issue
Block a user