大佬教程收集整理的这篇文章主要介绍了使用snapkit设置autolayout后,iOS框架出错,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的一步
1初始化subView
2将新的子视图添加到textView
3设置自动布局
4 set cornerRadius(view.frame.height / 2)
运行应用程序后,cornerRadius不会更改
然后我尝试打印subView的框架,得到(0,0)
这是我的代码
required init?(coder aDecoder: NSCoder) { super.init(coder: aDecoder) circelView = UIView() self.addSubview(circelView) circelView.snp_makeConsTraints(closure: { (makE) -> Void in make.size.equalTo(80) make.top.equalTo(self.snp_top) make.right.equalTo(self.snp_right) }) print(circelView.framE) //get wrong frame circelView.layer.cornerRadius = circelView.frame.size.height / 2 circelView.layer.masksToBounds = true }
要获得正确的结果,您需要在布局视图后设置角半径.这将保证您的框架受AutoLayout约束的约束.
为此,请在“viewDidLayoutSubviews”中放置任何需要正确框架的代码:
override func viewDidLayoutSubviews() { print(circelView.framE) // The frame will have been set circelView.layer.cornerRadius = circelView.frame.size.height / 2 }
以上是大佬教程为你收集整理的使用snapkit设置autolayout后,iOS框架出错全部内容,希望文章能够帮你解决使用snapkit设置autolayout后,iOS框架出错所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。