Setting Corner Radius on UIImageView not working

前端 未结 11 1902
心在旅途
心在旅途 2020-12-22 16:15

I\'m at a bit of a loss. I\'ve used the layer property of UIView to round the corners of multiple elements in my app. However, this one UIImageView is simply not complying.

11条回答
  •  温柔的废话
    2020-12-22 16:51

    Swift 4.2 Answer:

    In order for the corner radius to work, add the image to a UIView and then you need to set the image's masksToBounds property to true:

    planeImage.layer.masksToBounds = true
    planeImage.layer.cornerRadius = 20
    

    Note: Replace 20 by the desired cornerRadius

提交回复
热议问题