Image Cropping API for iOS

后端 未结 4 1378
一向
一向 2020-12-05 02:54

Is there any cropping image API for objective C that crops images dynamically in Xcode project? Please provide some tricks or techniques how could I crop camera images in iP

4条回答
  •  青春惊慌失措
    2020-12-05 03:26

    EDIT - Swift Version

    let imageView = UIImageView(image: image)
    imageView.contentMode = .scaleAspectFill
    imageView.clipsToBounds = true
    

    All these solutions seem quite complicated and many of them actually degrade the quality the image. You can do much simpler using UIImageView's out of the box methods.

    Objective-C

    self.imageView.contentMode = UIViewContentModeScaleAspectFill;
    [self.imageView setClipsToBounds:YES];
    [self.imageView setImage:img];
    

    This will crop your image based on the dimensions you've set for your UIImageView (I've called mine imageView here).
    It's that simple and works much better than the other solutions.

提交回复
热议问题