class RoundImage: UIImageView {
override func awakeFromNib() {
super.awakeFromNib()
setupView()
}
...
func setupView() {
self
I faced with this problem a few days ago.
You should add layoutIfNeeded()
before layer modifications.
In your case:
func setupView() {
self.layoutIfNeeded()
self.layer.borderWidth = borderWidth
self.layer.borderColor = borderColor
self.clipsToBounds = clip
self.layer.cornerRadius = self.frame.size.width / 2
}