Crop UIImage to fit a frame image

后端 未结 4 1222
眼角桃花
眼角桃花 2020-12-09 01:46

I need to crop a UIImage, taken with the device camera, so that it fits inside another UIImage, which represents a frame (with rounded

4条回答
  •  借酒劲吻你
    2020-12-09 02:11

    In interface Builder, access the Mode menu inside of the detail pane (the fourth one) and choose the right one for your UIImageView (I guess "center" or "aspect fit").

    enter image description here

    OLD ANSWER:

    You can use the contentGravity property of CALayer to make it work

    A constant that specifies how the layer's contents are positioned or scaled within its bounds.

           @property(copy) NSString *contentsGravity
    

提交回复
热议问题