How to make a circular UIView

前端 未结 7 1454
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 04:05

I want to make a UIView or UIImageView that is a circle. Or a circle that i can change the size of using a slider, and the color of with a pickerview.

相关标签:
7条回答
  • 2020-11-28 04:32

    If somebody is looking for Swift equivalent than below is the answer (Xcode7.2):

    (For this to work height and width must be equal.)

    extension UIView {
        func makeCircular() {
            self.layer.cornerRadius = min(self.frame.size.height, self.frame.size.width) / 2.0
            self.clipsToBounds = true
        }
    }
    

    0 讨论(0)
提交回复
热议问题