Open chengfengjie opened 6 years ago
设计图如下
实现左右排版: 用时间酿酒
的作者名称放在左边,不喜欢
的按钮放在右边
ASStackLayoutSpec.init(direction: ASStackLayoutDirection.horizontal,
spacing: self.cellNodeElementSpacing,
justifyContent:.spaceBetween,
alignItems:.center,
children: [authorSpec, self.unlikeButtonNode])
重点代码是 justifyContent
的参数应该是 .spaceBetween
,均分控件,如果只有两个控件,则一个在左一个在右
ASTextNode
的属性 maximumNumberOfLines
可能会不生效,需要设置truncationMode
属性为.byTruncatingTail
ASStackLayoutSpec
:向横向或者竖向的堆叠布局方式。初始化方法的参数
direction
: 横向(ASStackLayoutDirection.horizontal
) 竖向(ASStackLayoutDirection.vertical
)
spacing
: 堆叠的每一个元素的间距。一个CGFloat
justifyContent
: 一般是 .start
,均分是 spaceBetween
, 暂时用到的就这两个
alignItems
: 对齐方式,左对齐,右对齐, 居中对齐等等
children
: 堆叠的元素,一个数组
ASInsetLayoutSpec
: 这个是内边距, 其中 insets
参数是四个方向的内边距, child
是需要设置内边距的元素
ASRelativeLayoutSpec
: 这个是摆放位置的布局,例如:中心点,右上角等等这种布局就可以用这个
近期在写一个iOS的项目,用到了Texture。能大幅度提高iOS的流畅度。 项目文档地址: http://texturegroup.org github地址: https://github.com/texturegroup/texture
虽然用起来很爽,但是里面还是有一些坑,下面的笔记主要记录一些坑以及解决办法。