gpt4 book ai didi

ios - ASCellNode 内部水平布局显示错误

转载 作者:行者123 更新时间:2023-11-28 12:11:53 25 4
gpt4 key购买 nike

我使用 AsyncDisplayKit 编写了这段代码:

override open func layoutSpecThatFits(_ constrainedSize: ASSizeRange) -> ASLayoutSpec {

let horizonTitleDate = ASStackLayoutSpec(direction: .horizontal, spacing: 5, justifyContent: .start, alignItems: ASStackLayoutAlignItems.start, children: [title,space, datetime])
let verticalMess = ASStackLayoutSpec(direction: .vertical, spacing: 5, justifyContent: .start, alignItems: ASStackLayoutAlignItems.start, children: [horizonTitleDate, desc])
let horizonMess = ASStackLayoutSpec(direction: .horizontal, spacing: 5, justifyContent: .start, alignItems: ASStackLayoutAlignItems.start, children: [avatar, verticalMess])


//desc.style.width = ASDimensionMake(constrainedSize.max.width - 100)
desc.style.alignSelf = .stretch
desc.style.flexGrow = 1.0
desc.style.flexShrink = 1.0
verticalMess.style.alignSelf = .stretch
verticalMess.style.flexGrow = 1.0
horizonTitleDate.style.alignSelf = .stretch
let insets = UIEdgeInsetsMake(5, 5, 5, 5)
return ASInsetLayoutSpec(insets: insets, child: horizonMess)

}

我得到这个:

enter image description here

如你所见,黄色的 TextNode,比 cellNode 大,而且没有变成 2 行,在纵向模式下是这样的:

enter image description here

如果我只绘制没有头像的垂直布局,我会得到正确的 View :

enter image description here

怎么了?谢谢!

最佳答案

我没有看到 verticalMessflexShrink。尝试只添加这一行:

    verticalMess.style.flexShrink                  = 1.0

关于ios - ASCellNode 内部水平布局显示错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48190100/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com