当在 xib 中使用 Autolayout 后
设置 Frame 就不会生效
因为和 Autolayout 冲突
参考这篇文章
那要是非要想用 Autolayout 来布局怎么办?
其实有个很简单的办法可以兼容这两种需求
就是在 xib 外层 View 中加多一个 View 来使用 Autolayout

let numberV = Bundle.main.loadNibNamed("DCNumberV", owner: self, options: nil)?.last as! DCNumberV
v1.addSubview(numberV)
//这样就能在任何地方随意改变xibView的Frame
numberV.frame = CGRect.init(x: 0, y: 30, width: 300, height: 50)
网友评论