ios swift 3 xcode8 beta rounded imageView

前端 未结 1 753
猫巷女王i
猫巷女王i 2020-12-18 20:53

With my project I use the following code in order to make my images in rounded shape:

profileImage.layer.cornerRadius = profileImage.frame.size.width / 2
pro         


        
相关标签:
1条回答
  • 2020-12-18 21:10

    I had the same problem, the solution was just to move a line of code before your layer modifications. Try to apply layout changes:

    self.view.layoutIfNeeded()
    

    before your code:

    profileImage.layer.cornerRadius = profileImage.frame.size.width/2
    profileImage.clipsToBounds = true
    

    OR

    place your code related to frames / layers into viewDidLayoutSubviews() method:

    override func viewDidLayoutSubviews() {
    
        profileImage.layer.cornerRadius = profileImage.frame.size.width/2
        profileImage.clipsToBounds = true
    
    }
    
    0 讨论(0)
提交回复
热议问题