### CocoaPods Installation Source: https://github.com/timoliver/tocropviewcontroller/blob/main/README.md Instructions for installing TOCropViewController using CocoaPods. Separate pods are available for Objective-C and Swift projects. ```Ruby pod 'TOCropViewController' ``` ```Ruby pod 'CropViewController' ``` -------------------------------- ### Present TOCropViewController (Objective-C) Source: https://github.com/timoliver/tocropviewcontroller/blob/main/README.md Demonstrates the basic presentation of the TOCropViewController using Objective-C. It shows how to initialize the controller with an image and present it modally. The example also mentions the importance of dismissing the controller via delegate methods. ```Objective-C - (void)presentCropViewController { UIImage *image = ...; // Load an image TOCropViewController *cropViewController = [[TOCropViewController alloc] initWithImage:image]; cropViewController.delegate = self; [self presentViewController:cropViewController animated:YES completion:nil]; } - (void)cropViewController:(TOCropViewController *)cropViewController didCropToImage:(UIImage *)image withRect:(CGRect)cropRect angle:(NSInteger)angle { // 'image' is the newly cropped version of the original image } ``` -------------------------------- ### Carthage Installation Source: https://github.com/timoliver/tocropviewcontroller/blob/main/README.md Instructions for integrating TOCropViewController using Carthage. After updating, you need to link either the Objective-C or Swift framework into your Xcode project. ```Shell github "TimOliver/TOCropViewController" ``` -------------------------------- ### Swift Package Manager Installation Source: https://github.com/timoliver/tocropviewcontroller/blob/main/README.md Instructions for adding TOCropViewController as a dependency in your Swift Package Manager `Package.swift` file. ```Swift dependencies: [ // ... .package(url: "https://github.com/TimOliver/TOCropViewController.git"), ] ``` -------------------------------- ### Sharing Cropped Images Via a Share Sheet (Swift, Objective-C) Source: https://github.com/timoliver/tocropviewcontroller/blob/main/README.md Illustrates how to enable the built-in share sheet functionality upon completing the crop. Examples are provided for both Swift and Objective-C, setting the `showActivitySheetOnDone` property to `YES` or `true`. ```Swift func presentCropViewController() { var image: UIImage? // Load an image let cropViewController = CropViewController(image: image) cropViewController.showActivitySheetOnDone = true self.present(cropViewController, animated: true, completion: nil) } ``` ```Objective-C - (void)presentCropViewController { UIImage *image = ...; // Load an image TOCropViewController *cropViewController = [[TOCropViewController alloc] initWithImage:image]; cropViewController.showActivitySheetOnDone = YES; [self presentViewController:cropViewController animated:YES completion:nil]; } ``` -------------------------------- ### Making a Circular Cropped Image (Swift, Objective-C) Source: https://github.com/timoliver/tocropviewcontroller/blob/main/README.md Provides examples for both Swift and Objective-C to present the TOCropViewController configured for circular cropping. It shows initialization with `.circular` cropping style and the corresponding delegate method for receiving the circular cropped image. ```Swift func presentCropViewController() { var image: UIImage? // Load an image let cropViewController = CropViewController(croppingStyle: .circular, image: image) cropViewController.delegate = self self.present(cropViewController, animated: true, completion: nil) } func cropViewController(_ cropViewController: TOCropViewController?, didCropToCircularImage image: UIImage?, with cropRect: CGRect, angle: Int) { // 'image' is the newly cropped, circular version of the original image } ``` ```Objective-C - (void)presentCropViewController { UIImage *image = ...; // Load an image TOCropViewController *cropViewController = [[TOCropViewController alloc] initWithCroppingStyle:TOCropViewCroppingStyleCircular image:image]; cropViewController.delegate = self; [self presentViewController:cropViewController animated:YES completion:nil]; } - (void)cropViewController:(TOCropViewController *)cropViewController didCropToCircularImage:(UIImage *)image withRect:(CGRect)cropRect angle:(NSInteger)angle { // 'image' is the newly cropped, circular version of the original image } ``` -------------------------------- ### Basic Swift Crop Implementation Source: https://github.com/timoliver/tocropviewcontroller/blob/main/README.md Demonstrates how to present the Swift wrapper CropViewController to crop an image. It requires setting the delegate to receive the cropped image and crop rectangle. The controller can be presented modally or pushed onto a navigation stack. ```Swift func presentCropViewController() { let image: UIImage = ... //Load an image let cropViewController = CropViewController(image: image) cropViewController.delegate = self present(cropViewController, animated: true, completion: nil) } func cropViewController(_ cropViewController: CropViewController, didCropToImage image: UIImage, withRect cropRect: CGRect, angle: Int) { // 'image' is the newly cropped version of the original image } ``` -------------------------------- ### Presenting With a Custom Animation (Swift, Objective-C) Source: https://github.com/timoliver/tocropviewcontroller/blob/main/README.md Shows how to implement a custom presentation animation where a visible image view zooms into the crop view controller. This involves capturing the frame of the image view before presenting and using the `presentAnimatedFromParentViewController:fromFrame:completion:` method. ```Swift func presentCropViewController() { var image: UIImage? // Load an image var imageView = UIImageView(image: image) var frame: CGRect = view.convert(imageView.frame, to: view) let cropViewController = CropViewController(image: image) cropViewController.delegate = self self.present(cropViewController, animated: true, completion: nil) cropViewController.presentAnimated(fromParentViewController: self, fromFrame: frame, completion: nil) } ``` ```Objective-C - (void)presentCropViewController { UIImage *image = ...; UIImageView *imageView = [[UIImageView alloc] initWithImage:image]; CGRect frame = [self.view convertRect:imageView.frame toView:self.view]; TOCropViewController *cropViewController = [[TOCropViewController alloc] initWithImage:image]; cropViewController.delegate = self; [self presentViewController:cropViewController animated:YES completion:nil]; [cropViewController presentAnimatedFromParentViewController:self fromFrame:frame completion:nil]; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.