Storyboard and autolayout: how make a circular image

前端 未结 7 601
逝去的感伤
逝去的感伤 2021-01-01 02:27

in storyboard (xcode 6) i want a circular user image profile take from Facebook.

So i have make this interface in storyboard, using auto layout:

7条回答
  •  时光说笑
    2021-01-01 02:57

    SWIFT 3.x Just change your imageView custom class with this and enjoy.

    @IBDesignable class RoundedImageView:UIImageView {
        @IBInspectable var borderColor:UIColor = UIColor.white {
            willSet {
                layer.borderColor = newValue.cgColor
            }
        }
        override func layoutSubviews() {
            super.layoutSubviews()
            layer.cornerRadius = frame.height/2
            layer.masksToBounds = true
            layer.borderWidth = 1
            layer.borderColor = borderColor.cgColor
        }
    }
    

提交回复
热议问题