Skip to content

Commit 5ac2ce8

Browse files
committed
preparing for cocoapods
1 parent 662d2f2 commit 5ac2ce8

File tree

3 files changed

+81
-3
lines changed

3 files changed

+81
-3
lines changed

Example/CropperExample/CropperExample/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class ViewController: UIViewController {
1212

1313
@IBOutlet weak var imageView: UIImageView!
1414

15-
private var picker = UIImagePickerController()
15+
private let picker = UIImagePickerController()
1616
private let cropper = UIImageCropper(cropRatio: 2/3)
1717

1818
override func viewDidLoad() {

README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,82 @@
11
# UIImageCropper
22

3+
Simple Image cropper for UIImagePickerController with customisable crop aspect ratio. Made purely with Swift 4!
4+
5+
Replaces the iOS "crop only to square" functionality. Easy few line setup with delegate method/s.
6+
7+
## Requirements
8+
9+
- iOS10+
10+
- Xcode 9.2+
11+
- Swift 4
12+
13+
14+
## Install
15+
UIImageCropper is available through [CocoaPods](http://cocoapods.org). To install
16+
it, simply add the following line to your Podfile:
17+
18+
```
19+
pod 'UIImageCropper'
20+
```
21+
22+
(or add UIImageCropper folder to your project)
23+
24+
## Usage
25+
26+
Import the pod
27+
28+
```
29+
import UIImageCropper
30+
```
31+
32+
Create instanses of UIImagePickerController and UIImageCropper
33+
34+
UIImageCropper can take ```cropRatio``` as parameter. Default ratio is 1 (square).
35+
36+
```
37+
let picker = UIImagePickerController()
38+
let cropper = UIImageCropper(cropRatio: 2/3)
39+
```
40+
41+
Setup UIImageCropper
42+
43+
```
44+
cropper.picker = picker
45+
cropper.delegate = self
46+
//cropper.cropRatio = 2/3 //(can be set during runtime or in init)
47+
```
48+
49+
Implement ```UIImageCropperProtocol```delegate method/s
50+
51+
```
52+
func didCropImage(originalImage: UIImage?, croppedImage: UIImage?) {
53+
imageView.image = croppedImage
54+
}
55+
56+
//optional (if not implemented cropper will close itself and picker)
57+
func didCancel() {
58+
picker.dismiss(animated: true, completion: nil)
59+
}
60+
61+
```
62+
63+
The UIImageCropper will handle the image picking (delegate methods). To start image picking just present the UIImagePickerController instance.
64+
65+
```
66+
self.present(self.picker, animated: true, completion: nil)
67+
```
68+
69+
For full usage exmaple see **CropperExample** in Example folder.
70+
71+
## Coming soon
72+
73+
* Possibility to use cropper without UIImagePickerController
74+
75+
## Issues and contribution
76+
77+
If you find any issues please add and issue to this repository.
78+
79+
Improvements and/or fixes as pull requests are more than welcome.
380

481
## Author
582

UIImageCropper.podspec

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'UIImageCropper'
11-
s.version = '0.1.0'
11+
s.version = '1.0.0'
1212
s.summary = 'Simple Image cropper for UIImagePickerController with customisable aspect ratio.'
1313

1414
# This description is used to generate tags and improve search results.
@@ -18,7 +18,8 @@ Pod::Spec.new do |s|
1818
# * Finally, don't worry about the indent, CocoaPods strips it!
1919

2020
s.description = <<-DESC
21-
Simple Image cropper for UIImagePickerController with customisable aspect ratio. Made purely with Swift!
21+
Simple UIImage cropper for UIImagePickerController with customisable crop aspect ratio. Made purely with Swift4!
22+
Replaces the iOS "crop only to square" functionality. Easy few line setup with delegate method.
2223
DESC
2324

2425
s.homepage = 'https://github.com/jvk75/UIImageCropper'

0 commit comments

Comments
 (0)