I add a UIView to UIStoryboardand bind it to a custom UIView class called testView, then I create a UIView called subView in the textView in the function require init,
this is my step
1 initialization of subView
2 add a new subView to textView
3 set autorun
4 set cornerRadius (view.frame.height / 2)
After starting the application cornerRadius will not change
then I'm trying to print a subView frame, it gets (0,0,0,0)
this is my code
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)
circelView.layer.cornerRadius = circelView.frame.size.height / 2
circelView.layer.masksToBounds = true
}
source
share