Skip to content

Commit

Permalink
支持宽高设置浮点型
Browse files Browse the repository at this point in the history
  • Loading branch information
jingcheng1988 committed Dec 11, 2024
1 parent 7a3df30 commit 59fbc09
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
3 changes: 2 additions & 1 deletion GaiaXiOS/GaiaXiOS/Core/StretchKit/Classes/GXNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,11 @@ typedef NS_ENUM(NSUInteger, GXBindType) {

@end


@interface GXNode(JS)

//原始数据
@property (nonatomic, strong) GXTemplateData *orignalData;
@property (nonatomic, weak) GXTemplateData *orignalData;
//jsComponent
@property(nonatomic, strong) GaiaXJSComponent *jsComponent;

Expand Down
19 changes: 14 additions & 5 deletions GaiaXiOS/GaiaXiOS/Core/StretchKit/Classes/GXNode.m
Original file line number Diff line number Diff line change
Expand Up @@ -309,21 +309,30 @@ - (UIView *)superView{
//更新layout属性到node节点上
- (void)applyLayout:(GXLayout *)layout{
if (layout) {
//支持高度0.5设置
//支持宽度度0.x设置
CGFloat width = layout.width;
if ((width == 0 || width == 1) &&
self.style.styleModel.size.width.dimen_value < 1 &&
self.style.styleModel.size.width.dimen_type == DIM_TYPE_POINTS) {
width = self.style.styleModel.size.width.dimen_value;
}

// 支持高度0.x设置
CGFloat height = layout.height;
if (self.style.styleModel.size.height.dimen_value == 0.5 &&
if ((height == 0 || height == 1) &&
self.style.styleModel.size.height.dimen_value < 1 &&
self.style.styleModel.size.height.dimen_type == DIM_TYPE_POINTS) {
height = 0.5;
height = self.style.styleModel.size.height.dimen_value;
}

if (TheGXTemplateEngine.isNeedFlat && self.parent.isFlat) {
//如果有父节点 || 父节点被拍平
CGFloat x = layout.x + self.parent.frame.origin.x;
CGFloat y = layout.y + self.parent.frame.origin.y;
self.frame = CGRectMake(x, y, layout.width, height);
self.frame = CGRectMake(x, y, width, height);
} else {
//非拍平的情况
self.frame = CGRectMake(layout.x, layout.y, layout.width, height);
self.frame = CGRectMake(layout.x, layout.y, width, height);
}

//获取子node
Expand Down

0 comments on commit 59fbc09

Please sign in to comment.