iOS:DoricLayout use marginLeft and marginTop instead of x or y

This commit is contained in:
pengfei.zhou 2020-04-08 15:47:10 +08:00 committed by osborn
parent 2a7c7bd27d
commit e689d52f26
3 changed files with 4 additions and 8 deletions

View File

@ -65,8 +65,6 @@ typedef NS_ENUM(NSInteger, DoricGravity) {
@property(nonatomic, assign) CGFloat width; @property(nonatomic, assign) CGFloat width;
@property(nonatomic, assign) CGFloat height; @property(nonatomic, assign) CGFloat height;
@property(nonatomic, assign) CGFloat x;
@property(nonatomic, assign) CGFloat y;
@property(nonatomic, assign) CGFloat spacing; @property(nonatomic, assign) CGFloat spacing;

View File

@ -37,8 +37,6 @@ - (DoricLayout *)doricLayout {
layout = [DoricLayout new]; layout = [DoricLayout new];
layout.width = self.width; layout.width = self.width;
layout.height = self.height; layout.height = self.height;
layout.x = self.x;
layout.y = self.y;
layout.view = self; layout.view = self;
self.doricLayout = layout; self.doricLayout = layout;
} }
@ -360,7 +358,7 @@ - (void)layoutStack {
if (layout.marginLeft || layout.marginRight) { if (layout.marginLeft || layout.marginRight) {
layout.measuredX = self.paddingLeft; layout.measuredX = self.paddingLeft;
} else { } else {
layout.measuredX = layout.x; layout.measuredX = 0;
} }
} }
if ((gravity & DoricGravityTop) == DoricGravityTop) { if ((gravity & DoricGravityTop) == DoricGravityTop) {
@ -373,7 +371,7 @@ - (void)layoutStack {
if (layout.marginTop || layout.marginBottom) { if (layout.marginTop || layout.marginBottom) {
layout.measuredY = self.paddingTop; layout.measuredY = self.paddingTop;
} else { } else {
layout.measuredY = layout.y; layout.measuredY = 0;
} }
} }

View File

@ -173,9 +173,9 @@ - (void)blendView:(UIView *)view forPropName:(NSString *)name propValue:(id)prop
} else if ([name isEqualToString:@"height"]) { } else if ([name isEqualToString:@"height"]) {
view.doricLayout.height = [prop floatValue]; view.doricLayout.height = [prop floatValue];
} else if ([name isEqualToString:@"x"]) { } else if ([name isEqualToString:@"x"]) {
view.doricLayout.x = [prop floatValue]; view.doricLayout.marginLeft = [prop floatValue];
} else if ([name isEqualToString:@"y"]) { } else if ([name isEqualToString:@"y"]) {
view.doricLayout.y = [prop floatValue]; view.doricLayout.marginTop = [prop floatValue];
} else if ([name isEqualToString:@"backgroundColor"]) { } else if ([name isEqualToString:@"backgroundColor"]) {
if ([prop isKindOfClass:[NSNumber class]]) { if ([prop isKindOfClass:[NSNumber class]]) {
view.backgroundColor = DoricColor(prop); view.backgroundColor = DoricColor(prop);