Cropping image with Swift and put it on center position

后端 未结 14 1155
心在旅途
心在旅途 2020-12-01 00:32

In Swift programming , how do you crop an image and put it on the center afterwards?

This is what I\'ve got so far ... I\'ve successfully crop the image but I want t

14条回答
  •  时光取名叫无心
    2020-12-01 01:29

    In swift 4.1 I would do simply:

    imageView.clipsToBounds = true
    imageView.contentMode = .scaleAspectFill
    imageView.layer.cornerRadius = 20
    

    Credits to Stretching, Redrawing and Positioning with contentMode

提交回复
热议问题