0
我以编程方式创建容器视图。但是,我无法改变它的身高。我以编程方式设置它,但没有任何影响。以编程方式创建UIContainerView()并更改其高度
let supportView: UIView = UIView()
let containerView = UIView()
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(true)
self.containerView.frame = CGRect(x: self.view.frame.size.width - 100, y: 200, width: 225, height: 70)
print(self.containerView.frame.height)
self.containerView.backgroundColor = UIColor.gray
self.containerView.layer.cornerRadius = 20
self.view.addSubview(self.containerView)
let controller = storyboard!.instantiateViewController(withIdentifier: "Storyboard2")
addChildViewController(controller)
containerView.addSubview(controller.view)
controller.didMove(toParentViewController: self)
}
我创建故事板具有标识符“Storyboard2”视图控制器。而且我已经把它的高度设置在70了。但没有任何运气。 任何帮助?由于
你有没有在故事板中添加约束?你真的需要以编程方式创建容器视图吗? –
可能重复的[我可以创建一个UIContainerView程序?](http://stackoverflow.com/questions/29694628/can-i-create-a-uicontainerview-programatically) – dirtydanee
作为一个方面说明,没有这样的事情'UIContainerView()'。 – dirtydanee