mamaral / Neon

A powerful Swift programmatic UI layout framework.
MIT License
4.58k stars 389 forks source link

How to layout a table with equal cell height and width? #27

Open horaceho opened 8 years ago

horaceho commented 8 years ago

Give a resizable UIView, what is the proper way to layout a 3 x 4 table with equal width and height for each cell?

For example, when the view is 120 x 120, each cell is 40 x 30. When the view is resize to 240 x 360, each cell changes to 80 x 90.

cactis commented 8 years ago

maybe such as....

if a is a resizable view

add r1 view to a add r1c1, r1c2, r1c3 to r1

add r2 view to a and r2c1, r2c2, r2c3 .... add r3 view to a and r3c1, r3c2, r3c3....

and groupAndFill them.... a.groupAndFill(group: .Vertical, views: [r1, r2, r3], padding: 0) r1.groupAndFill(group: .Horizontal, views: [r1c1, r1c2, r1c3], padding: 0) r2.groupAndFill(group: .Horizontal, views: [r2c1, r2c2, r2c3], padding: 0) r3.groupAndFill(group: .Horizontal, views: [r3c1, r3c2, r3c3], padding: 0)

tim12s commented 8 years ago

I dont mind looking at this, i'm looking for something similar allowing certain "cells" to be merged and then have the cell layout altered once the handset/device is rotated. E.g. 3x4 vs 4x3.