gpt4 book ai didi

ios - 如何制作此网格布局

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:53:20 25 4
gpt4 key购买 nike

我需要这个网格布局,带有 Storyboard 的 View 结构。是不是更简单的设置方式,还是我需要计算大小/4,乘以索引,计算中心X、Y坐标,并在每次旋转时调整NSLayoutConstraint

enter image description here

最佳答案

您可以使用默认垂直的 UIStackView 并在横向尺寸类中将其轴更改为水平,分布 Fill-Equally

override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {

if UIDevice.current.orientation == .portrait
{
self.stackV.axis = .vertical
}
else
{
self.stackV.axis = .horizontal
}

}

关于ios - 如何制作此网格布局,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49388345/

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