使用自动布局约束动态创建视图?在 Objective-C?

Creating views dynamically with autolayout constraints? in Objective-C?

所有这些都是有约束的编程方式。并且可能是 UILabel 的 UIView 或 UIButtons 被创建到循环中。一个一个。

请帮忙!!

如果您想以编程方式创建这些视图,我会推荐这两个库。它们使 adding/removing/updating/managing 约束变得非常容易。

Objective-c

https://github.com/SnapKit/Masonry

Swift

https://github.com/SnapKit/SnapKit

您可以使用 apple Native NSLayoutAnchor 以编程方式创建约束。像 SnapKit/Masonry.

一样简单