Swift:从另一个 class 更改容器高度和原点
Swift: Change Container height and origin from another class
我有一个主视图控制器,在该控制器中我有两个容器。我想通过按下底部视图控制器中的按钮来更改顶部容器的原点。一个简单的顶部抽屉。你可以猜到我是初学者。
我无法将顶部容器引用到我的 bottomViewController class。
谢谢
科雷·比兰德
声明一个变量,指出您在其上方的 class。
并在其中 class 添加一个函数,将相关约束常量的 iboulet 更改为所需值。
var mV = MainViewController()
class MainViewController: UIViewController {
@IBOutlet weak var topAlign: NSLayoutConstraint!
func moveTop () {
topAlign.constant = 100
}
}
然后在另一个 class 中调用函数:
mV.moveTop()
我有一个主视图控制器,在该控制器中我有两个容器。我想通过按下底部视图控制器中的按钮来更改顶部容器的原点。一个简单的顶部抽屉。你可以猜到我是初学者。
我无法将顶部容器引用到我的 bottomViewController class。
谢谢 科雷·比兰德
声明一个变量,指出您在其上方的 class。 并在其中 class 添加一个函数,将相关约束常量的 iboulet 更改为所需值。
var mV = MainViewController()
class MainViewController: UIViewController {
@IBOutlet weak var topAlign: NSLayoutConstraint!
func moveTop () {
topAlign.constant = 100
}
}
然后在另一个 class 中调用函数:
mV.moveTop()