用于约束的 IBOutlet 并以编程方式将其连接到 UIButton
IBOutlet for constraint and connect that to a UIButton programatically
我想要一个自定义 IBOutlet
作为对 UIButton
的约束,以便我可以在 UITableViewCell
中修改它。我想使用 if/else 条件更改 UIButton
的高度。
您需要将 UITableViewCell 子类化,然后 link 将您的约束放入其中,或者在您的约束上使用标识符,然后使用如下循环从视图中获取约束:
for (UIView *subview in view.subviews) {
for (NSLayoutConstraint *constraint in subview.constraints) {
if ([constraint.identifier isEqualToString:identifier]) {
return constraint;
}
}
}
我想要一个自定义 IBOutlet
作为对 UIButton
的约束,以便我可以在 UITableViewCell
中修改它。我想使用 if/else 条件更改 UIButton
的高度。
您需要将 UITableViewCell 子类化,然后 link 将您的约束放入其中,或者在您的约束上使用标识符,然后使用如下循环从视图中获取约束:
for (UIView *subview in view.subviews) {
for (NSLayoutConstraint *constraint in subview.constraints) {
if ([constraint.identifier isEqualToString:identifier]) {
return constraint;
}
}
}