Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TGFlowLayout 子视图平均布局,宽高相等 #31

Closed
jprothwell opened this issue Dec 1, 2018 · 2 comments
Closed

TGFlowLayout 子视图平均布局,宽高相等 #31

jprothwell opened this issue Dec 1, 2018 · 2 comments

Comments

@jprothwell
Copy link

jprothwell commented Dec 1, 2018

请问这样的子视图怎么设置,或者父视图怎么设置?
ps:
其实就是利用TGFlowLayout设计9宫格布局[但是不完全只有9个子视图,可能[0-n],是需要动态添加的]

Code

imageLayout = TGFlowLayout(.vert, arrangedCount: 3)
        imageLayout.tg_space = 5
        imageLayout.tg_height.equal(.wrap)
        imageLayout.tg_gravity = TGGravity.horz.fill
        imageLayout.tg_width.equal(.fill)

当加入子视图时候.自动宽高相等

@jprothwell jprothwell changed the title TGFlowLayout 子视图平均布局已经宽高相等 TGFlowLayout 子视图平均布局,宽高相等 Dec 1, 2018
@youngsoft
Copy link
Owner

您所谓的子视图添加时的自动宽高相等是什么意思?是让宽度均分?子视图的高度等于宽度吗? 如果是这样的需求的话,你只需要在你上面代码的基础上将你的子视图的高度设置为等于宽度,其他的什么也不需要写。

subview.tg_height.equal(subview.tg_width)

@jprothwell
Copy link
Author

您所谓的子视图添加时的自动宽高相等是什么意思?是让宽度均分?子视图的高度等于宽度吗? 如果是这样的需求的话,你只需要在你上面代码的基础上将你的子视图的高度设置为等于宽度,其他的什么也不需要写。

subview.tg_height.equal(subview.tg_width)

好的.我试试.本以为只有相对布局能这样设置

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants