├── Resources └── ChopChop-cover.png ├── Demo ├── ChopChop │ ├── Assets.xcassets │ │ └── AppIcon.appiconset │ │ │ ├── Icon29@2x.png │ │ │ ├── Icon29@3x.png │ │ │ ├── app-icon-ipad.png │ │ │ ├── app-icon-ipad@2x.png │ │ │ ├── app-icon-iphone@2x.png │ │ │ ├── app-icon-iphone@3x.png │ │ │ ├── app-icon-spotlight-1.png │ │ │ ├── app-icon-spotlight.png │ │ │ ├── app-icon-spotlight@2x.png │ │ │ ├── app-icon-spotlight@3x.png │ │ │ ├── app-icon-spotlight@2x-1.png │ │ │ ├── app-icon-spotlight@2x-2.png │ │ │ └── Contents.json │ ├── ImageCollectionViewCell.swift │ ├── ImageCollectionViewController.swift │ ├── Info.plist │ ├── Base.lproj │ │ ├── LaunchScreen.storyboard │ │ └── Main.storyboard │ ├── AppDelegate.swift │ ├── ImagePickerViewController.swift │ └── ChopChop │ │ └── ChopChop.swift └── ChopChop.xcodeproj │ ├── xcuserdata │ └── pavankataria.xcuserdatad │ │ ├── xcdebugger │ │ └── Breakpoints_v2.xcbkptlist │ │ └── xcschemes │ │ ├── xcschememanagement.plist │ │ └── ChopChop.xcscheme │ ├── project.xcworkspace │ ├── xcuserdata │ │ └── pavankataria.xcuserdatad │ │ │ └── UserInterfaceState.xcuserstate │ └── contents.xcworkspacedata │ └── project.pbxproj ├── LICENSE ├── README.md └── Src └── PKImageUtil.swift /Resources/ChopChop-cover.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Resources/ChopChop-cover.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/Icon29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/Icon29@2x.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/Icon29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/Icon29@3x.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-ipad.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-ipad@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-ipad@2x.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-iphone@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-iphone@2x.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-iphone@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-iphone@3x.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight-1.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight.png -------------------------------------------------------------------------------- /Demo/ChopChop.xcodeproj/xcuserdata/pavankataria.xcuserdatad/xcdebugger/Breakpoints_v2.xcbkptlist: -------------------------------------------------------------------------------- 1 | 2 | 5 | 6 | -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight@2x.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight@3x.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight@2x-1.png -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight@2x-2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/app-icon-spotlight@2x-2.png -------------------------------------------------------------------------------- /Demo/ChopChop.xcodeproj/project.xcworkspace/xcuserdata/pavankataria.xcuserdatad/UserInterfaceState.xcuserstate: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pavankataria/ChopChop/HEAD/Demo/ChopChop.xcodeproj/project.xcworkspace/xcuserdata/pavankataria.xcuserdatad/UserInterfaceState.xcuserstate -------------------------------------------------------------------------------- /Demo/ChopChop.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Demo/ChopChop/ImageCollectionViewCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageCollectionViewCell.swift 3 | // PKImageMatrixCropper 4 | // 5 | // Created by Pavan Kataria on 10/01/2016. 6 | // Copyright © 2016 Pavan Kataria. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ImageCollectionViewCell: UICollectionViewCell { 12 | @IBOutlet weak var croppedImageView: UIImageView! 13 | func setImage(image: UIImage){ 14 | croppedImageView.image = image 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /Demo/ChopChop.xcodeproj/xcuserdata/pavankataria.xcuserdatad/xcschemes/xcschememanagement.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | SchemeUserState 6 | 7 | ChopChop.xcscheme 8 | 9 | orderHint 10 | 1 11 | 12 | 13 | SuppressBuildableAutocreation 14 | 15 | 05D114141C41F22C00EF50D5 16 | 17 | primary 18 | 19 | 20 | 05D114281C41F22C00EF50D5 21 | 22 | primary 23 | 24 | 25 | 05D114331C41F22C00EF50D5 26 | 27 | primary 28 | 29 | 30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2016 pavankataria 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Demo/ChopChop/ImageCollectionViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImageCollectionViewController.swift 3 | // PKImageMatrixCropper 4 | // 5 | // Created by Pavan Kataria on 10/01/2016. 6 | // Copyright © 2016 Pavan Kataria. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private let reuseIdentifier = "ImageCell" 12 | 13 | class ImageCollectionViewController: UICollectionViewController { 14 | var images = [UIImage]() { 15 | didSet { 16 | self.collectionView?.reloadData() 17 | } 18 | } 19 | 20 | override func viewDidLoad() { 21 | super.viewDidLoad() 22 | } 23 | 24 | override func didReceiveMemoryWarning() { 25 | super.didReceiveMemoryWarning() 26 | } 27 | 28 | override func numberOfSectionsInCollectionView(collectionView: UICollectionView) -> Int { 29 | return 1 30 | } 31 | 32 | 33 | override func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int 34 | { 35 | return images.count 36 | } 37 | 38 | override func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 39 | let cell = collectionView.dequeueReusableCellWithReuseIdentifier(reuseIdentifier, forIndexPath: indexPath) as! ImageCollectionViewCell 40 | 41 | let image = images[indexPath.row] 42 | cell.setImage(image) 43 | return cell 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Demo/ChopChop/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /Demo/ChopChop/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Demo/ChopChop/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon29@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon29@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "app-icon-spotlight@2x.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "app-icon-spotlight@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "app-icon-iphone@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "app-icon-iphone@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "app-icon-spotlight-1.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "app-icon-spotlight@2x-2.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "app-icon-spotlight.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "app-icon-spotlight@2x-1.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "app-icon-ipad.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "app-icon-ipad@2x.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "idiom" : "ipad", 77 | "size" : "83.5x83.5", 78 | "scale" : "2x" 79 | } 80 | ], 81 | "info" : { 82 | "version" : 1, 83 | "author" : "xcode" 84 | } 85 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![ChopChop](https://github.com/pavankataria/ChopChop/blob/master/Resources/ChopChop-cover.png) 2 | 3 | ## Description 4 | 5 | Chop an image to as many quadrants as you like at compile time. 6 | Suitable for games and image processing. 7 | 8 | Great for dynamic content, s 9 | 10 | Here's what you can do with this package: 11 | 12 | - You can crop an image into a square 13 | - You can crop an image into as many quadrants as you like, by specifying the number of rows and columns, a matrix. 14 | 15 | ### Screenshots of Demo 16 |

17 | 18 |

19 | 20 |

21 |

22 |
23 | 24 | ### Demo 25 | A demo is available which allows you: 26 | - to pick an image, 27 | - specify your matrix 28 | - and view your chopped up image into a nice collection view 29 | 30 | ### Installation 31 | 32 | There isn't a cocoapod for this package as of today, didn't have the time to do so just yet. 33 | For now, simply dragging the single source file into your project is all that's required. 34 | 35 | ### How to use 36 | You simply have an instance of a UIImage you loaded yourself, from somewhere, anywhere: 37 | ```Swift 38 | var myImage = UIImage(imageNamed:"maybe from the assets, or the image picker class") 39 | ``` 40 | Define and instantiate an array which will hold your cropped UIImages 41 | ```Swift 42 | var images = [UIImage]() 43 | ``` 44 | 45 | 46 | You can either crop your image into a nice square 47 | ```Swift 48 | var profileImageView.image = myImage.cropToSquare() 49 | ``` 50 | 51 | Or if you want to make a game or something and require your images to be cropped up into equal quadrants then simply pass a matrix into the cropWithMatrix method. 52 | You need to insert a tuple which consists of two ints which are attributed to rows and columns. 53 | ```Swift 54 | let rowsNum = 2 55 | let colsNum = 2 56 | images = image.cropWithMatrix((rowsNum, colsNum)) 57 | ``` 58 | 59 | You'll then get your very own images array which contains your cropped/chopped up image. 60 | 61 | ### To-dos 62 | + Implement background processing within the package 63 | + Add more helper functions to the PKImageMatrixCropper 64 | + Write Tests 65 | 66 | ### Roadmap 67 | - We are open to new and awesome ideas, contribute if you like! :) 68 | 69 | ## Contribute 70 | 71 | 1. Fork it 72 | 2. Create your feature branch (`git checkout -b my-new-feature`) 73 | 3. Commit your changes (`git commit -am 'Add some feature'`) 74 | 4. Push to the branch (`git push origin my-new-feature`) 75 | 5. Create pull request 76 | 77 | 78 | ## License 79 | 80 | **ChopChop** is available under the MIT license. 81 | -------------------------------------------------------------------------------- /Demo/ChopChop/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PKImageMatrixCropper 4 | // 5 | // Created by Pavan Kataria on 10/01/2016. 6 | // Copyright © 2016 Pavan Kataria. All rights reserved. 7 | // 8 | /* 9 | The MIT License (MIT) 10 | 11 | Copyright (c) [2016] [Pavan Kataria] 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all 21 | copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 | SOFTWARE. 30 | */ 31 | 32 | import UIKit 33 | 34 | @UIApplicationMain 35 | class AppDelegate: UIResponder, UIApplicationDelegate { 36 | 37 | var window: UIWindow? 38 | 39 | 40 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 41 | // Override point for customization after application launch. 42 | return true 43 | } 44 | 45 | func applicationWillResignActive(application: UIApplication) { 46 | // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. 47 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 48 | } 49 | 50 | func applicationDidEnterBackground(application: UIApplication) { 51 | // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. 52 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 53 | } 54 | 55 | func applicationWillEnterForeground(application: UIApplication) { 56 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 57 | } 58 | 59 | func applicationDidBecomeActive(application: UIApplication) { 60 | // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. 61 | } 62 | 63 | func applicationWillTerminate(application: UIApplication) { 64 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 65 | } 66 | 67 | 68 | } 69 | 70 | -------------------------------------------------------------------------------- /Demo/ChopChop.xcodeproj/xcuserdata/pavankataria.xcuserdatad/xcschemes/ChopChop.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 39 | 40 | 41 | 42 | 43 | 44 | 54 | 56 | 62 | 63 | 64 | 65 | 66 | 67 | 73 | 75 | 81 | 82 | 83 | 84 | 86 | 87 | 90 | 91 | 92 | -------------------------------------------------------------------------------- /Demo/ChopChop/ImagePickerViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ImagePickerViewController.swift 3 | // PKImageMatrixCropper 4 | // 5 | // Created by Pavan Kataria on 10/01/2016. 6 | // Copyright © 2016 Pavan Kataria. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | enum SegueIdentifiers: String { 12 | case ImageViewer = "ShowImageViewer" 13 | } 14 | 15 | class ImagePickerViewController: UIViewController { 16 | @IBOutlet weak var pickedImage: UIImageView! 17 | @IBOutlet weak var rows: UITextField! 18 | @IBOutlet weak var cols: UITextField! 19 | 20 | var image: UIImage { 21 | set { 22 | pickedImage.image = newValue 23 | self.navigationItem.rightBarButtonItem?.enabled = true 24 | } 25 | get { 26 | if let image = pickedImage.image { 27 | return image 28 | } 29 | assertionFailure("image is nil") 30 | return UIImage() 31 | } 32 | } 33 | var images = [UIImage]() 34 | let imagePicker = UIImagePickerController() 35 | 36 | override func viewDidLoad() { 37 | super.viewDidLoad() 38 | let pickerButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.Camera, target: self, action: "displayPicker") 39 | 40 | let processButton = UIBarButtonItem(title: "Process", style: UIBarButtonItemStyle.Done, target: self, action: Selector("process")) 41 | processButton.enabled = false 42 | self.navigationItem.leftBarButtonItem? = pickerButton 43 | self.navigationItem.rightBarButtonItem? = processButton 44 | 45 | imagePicker.delegate = self 46 | displayHowToUseMessage() 47 | } 48 | 49 | func process(){ 50 | if rows.text?.characters.count == 0 { 51 | rows.text = "2" 52 | } 53 | if cols.text?.characters.count == 0 { 54 | cols.text = "2" 55 | } 56 | var rowsNum: Int = 2 57 | var colsNum: Int = 2 58 | if let text = rows.text { 59 | rowsNum = Int(text)! 60 | } 61 | if let text = cols.text { 62 | colsNum = Int(text)! 63 | } 64 | 65 | // You can use this method to chop by four 66 | // images = image.cropToFourQuadrantsWithResize() 67 | images = image.cropWithMatrix((rowsNum, colsNum)) 68 | performSegueWithIdentifier(SegueIdentifiers.ImageViewer.rawValue, sender: self) 69 | } 70 | 71 | override func didReceiveMemoryWarning() { 72 | super.didReceiveMemoryWarning() 73 | // Dispose of any resources that can be recreated. 74 | } 75 | 76 | func displayHowToUseMessage(){ 77 | let alertController = UIAlertController(title: "How to use", message: "Pick an image,\nspecify a small number for both rows and columns,\nthen tap process", preferredStyle: UIAlertControllerStyle.Alert) 78 | let action = UIAlertAction(title: "Ok", style: UIAlertActionStyle.Default, handler: nil) 79 | alertController.addAction(action) 80 | presentViewController(alertController, animated: true, completion: nil) 81 | } 82 | 83 | // In a storyboard-based application, you will often want to do a little preparation before navigation 84 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) { 85 | if segue.identifier == SegueIdentifiers.ImageViewer.rawValue { 86 | let controller = segue.destinationViewController as! ImageCollectionViewController 87 | controller.images = images 88 | } 89 | } 90 | } 91 | extension ImagePickerViewController: UIImagePickerControllerDelegate, UINavigationControllerDelegate { 92 | func displayPicker(){ 93 | imagePicker.allowsEditing = true 94 | imagePicker.sourceType = .PhotoLibrary 95 | presentViewController(imagePicker, animated: true, completion: nil) 96 | } 97 | func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) { 98 | if let pickedImage = info[UIImagePickerControllerEditedImage] as? UIImage { 99 | self.pickedImage.contentMode = .ScaleAspectFill 100 | self.image = pickedImage 101 | } 102 | dismissViewControllerAnimated(true, completion: nil) 103 | } 104 | } -------------------------------------------------------------------------------- /Src/PKImageUtil.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChopChop.swift 3 | // ChopChop 4 | // 5 | // Created by Pavan Kataria on 10/01/2016. 6 | // Copyright © 2016 Pavan Kataria. All rights reserved. 7 | // 8 | /* 9 | The MIT License (MIT) 10 | 11 | Copyright (c) [2016] [Pavan Kataria] 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all 21 | copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 | SOFTWARE. 30 | */ 31 | 32 | import Foundation 33 | import UIKit 34 | 35 | protocol ChopChopProtocol { 36 | func cropToSquare() -> UIImage 37 | func cropWithMatrix(matrix: (rows: Int, cols: Int)) -> [UIImage] 38 | } 39 | extension UIImage: ChopChopProtocol { 40 | func cropToSquare() -> UIImage 41 | { 42 | return ChopChop.cropToSquare(image: self) 43 | } 44 | func cropWithMatrix(matrix: (rows: Int, cols: Int)) -> [UIImage] 45 | { 46 | return ChopChop.cropImage(image: self, toMatrix: (rows: 2, cols: 2)) 47 | } 48 | } 49 | 50 | class ChopChop: NSObject { 51 | 52 | // Crops to square based on the shortest length 53 | static func cropToSquare(image originalImage: UIImage) -> UIImage { 54 | let imageSize: CGSize = originalImage.size 55 | let posX: CGFloat 56 | let posY: CGFloat 57 | let width: CGFloat 58 | let height: CGFloat 59 | 60 | if imageSize.width > imageSize.height { 61 | posX = ((imageSize.width - imageSize.height) / 2) 62 | posY = 0 63 | width = imageSize.height 64 | height = imageSize.height 65 | } else { 66 | posX = 0 67 | posY = ((imageSize.height - imageSize.width) / 2) 68 | width = imageSize.width 69 | height = imageSize.width 70 | } 71 | 72 | let rect: CGRect = CGRectMake(posX, posY, width, height) 73 | return self.crop(image: originalImage, cropRect: rect) 74 | } 75 | 76 | // A matrix cropper 77 | static func cropImage(image originalImage: UIImage, toMatrix matrix: (rows: Int, cols: Int)) -> [UIImage]{ 78 | //TODO: 79 | /* guard originalSquareImage.size.width % matrix.rows == 0 && 80 | originalSquareImage.size.height % matrix.cols == 0 else { 81 | assertionFailure("For now, the square image needs to divide exactly by the matrix provided, at least until this package is further developed to handle odd image sized edge cases.") 82 | } 83 | */ 84 | var images = [UIImage]() 85 | let quadrantSize: CGSize = CGSize(width: CGFloat(Int(originalImage.size.width) / matrix.rows), height: CGFloat(Int(originalImage.size.height) / matrix.cols)) 86 | 87 | for rowPosition in 0 ..< matrix.rows { 88 | for colPosition in 0 ..< matrix.cols { 89 | let x: CGFloat = CGFloat(rowPosition * Int(quadrantSize.width)) 90 | let y: CGFloat = CGFloat(colPosition * Int(quadrantSize.height)) 91 | let rect = CGRect(x: x, y: y, width: quadrantSize.width, height: quadrantSize.height) 92 | images.append(self.crop(image: originalImage, cropRect: rect)) 93 | } 94 | } 95 | return images 96 | } 97 | 98 | // Crops image to specified rect 99 | static func crop(image originalImage: UIImage, cropRect originalCropRect: CGRect) -> UIImage{ 100 | let contextImage: UIImage = UIImage(CGImage: originalImage.CGImage!) 101 | let imageRef: CGImageRef = CGImageCreateWithImageInRect(contextImage.CGImage, originalCropRect)! 102 | let image: UIImage = UIImage(CGImage: imageRef, scale: originalImage.scale, orientation: originalImage.imageOrientation) 103 | return image 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Demo/ChopChop/ChopChop/ChopChop.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ChopChop.swift 3 | // ChopChop 4 | // 5 | // Created by Pavan Kataria on 10/01/2016. 6 | // Copyright © 2016 Pavan Kataria. All rights reserved. 7 | // 8 | /* 9 | The MIT License (MIT) 10 | 11 | Copyright (c) [2016] [Pavan Kataria] 12 | 13 | Permission is hereby granted, free of charge, to any person obtaining a copy 14 | of this software and associated documentation files (the "Software"), to deal 15 | in the Software without restriction, including without limitation the rights 16 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 17 | copies of the Software, and to permit persons to whom the Software is 18 | furnished to do so, subject to the following conditions: 19 | 20 | The above copyright notice and this permission notice shall be included in all 21 | copies or substantial portions of the Software. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 29 | SOFTWARE. 30 | */ 31 | 32 | import Foundation 33 | import UIKit 34 | 35 | protocol ChopChopProtocol { 36 | func cropToSquare() -> UIImage 37 | func cropWithMatrix(matrix: (rows: Int, cols: Int)) -> [UIImage] 38 | } 39 | extension UIImage: ChopChopProtocol { 40 | func cropToSquare() -> UIImage 41 | { 42 | return ChopChop.cropToSquare(image: self) 43 | } 44 | func cropWithMatrix(matrix: (rows: Int, cols: Int)) -> [UIImage] 45 | { 46 | return ChopChop.cropImage(image: self, toMatrix: (rows: 2, cols: 2)) 47 | } 48 | } 49 | 50 | class ChopChop: NSObject { 51 | 52 | // Crops to square based on the shortest length 53 | static func cropToSquare(image originalImage: UIImage) -> UIImage { 54 | let imageSize: CGSize = originalImage.size 55 | let posX: CGFloat 56 | let posY: CGFloat 57 | let width: CGFloat 58 | let height: CGFloat 59 | 60 | if imageSize.width > imageSize.height { 61 | posX = ((imageSize.width - imageSize.height) / 2) 62 | posY = 0 63 | width = imageSize.height 64 | height = imageSize.height 65 | } else { 66 | posX = 0 67 | posY = ((imageSize.height - imageSize.width) / 2) 68 | width = imageSize.width 69 | height = imageSize.width 70 | } 71 | 72 | let rect: CGRect = CGRectMake(posX, posY, width, height) 73 | return self.crop(image: originalImage, cropRect: rect) 74 | } 75 | 76 | // A matrix cropper 77 | static func cropImage(image originalImage: UIImage, toMatrix matrix: (rows: Int, cols: Int)) -> [UIImage]{ 78 | //TODO: 79 | /* guard originalSquareImage.size.width % matrix.rows == 0 && 80 | originalSquareImage.size.height % matrix.cols == 0 else { 81 | assertionFailure("For now, the square image needs to divide exactly by the matrix provided, at least until this package is further developed to handle odd image sized edge cases.") 82 | } 83 | */ 84 | var images = [UIImage]() 85 | let quadrantSize: CGSize = CGSize(width: CGFloat(Int(originalImage.size.width) / matrix.rows), height: CGFloat(Int(originalImage.size.height) / matrix.cols)) 86 | 87 | for rowPosition in 0 ..< matrix.rows { 88 | for colPosition in 0 ..< matrix.cols { 89 | let x: CGFloat = CGFloat(rowPosition * Int(quadrantSize.width)) 90 | let y: CGFloat = CGFloat(colPosition * Int(quadrantSize.height)) 91 | let rect = CGRect(x: x, y: y, width: quadrantSize.width, height: quadrantSize.height) 92 | images.append(self.crop(image: originalImage, cropRect: rect)) 93 | } 94 | } 95 | return images 96 | } 97 | 98 | // Crops image to specified rect 99 | static func crop(image originalImage: UIImage, cropRect originalCropRect: CGRect) -> UIImage{ 100 | let contextImage: UIImage = UIImage(CGImage: originalImage.CGImage!) 101 | let imageRef: CGImageRef = CGImageCreateWithImageInRect(contextImage.CGImage, originalCropRect)! 102 | let image: UIImage = UIImage(CGImage: imageRef, scale: originalImage.scale, orientation: originalImage.imageOrientation) 103 | return image 104 | } 105 | } 106 | -------------------------------------------------------------------------------- /Demo/ChopChop.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 052DD50F1C47B74000D88F8E /* ChopChop.swift in Sources */ = {isa = PBXBuildFile; fileRef = 052DD50E1C47B74000D88F8E /* ChopChop.swift */; }; 11 | 052DD5131C47B8A000D88F8E /* Info.plist in Resources */ = {isa = PBXBuildFile; fileRef = 052DD5121C47B8A000D88F8E /* Info.plist */; }; 12 | 052DD5181C47B90C00D88F8E /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 052DD5141C47B90C00D88F8E /* LaunchScreen.storyboard */; }; 13 | 052DD5191C47B90C00D88F8E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 052DD5161C47B90C00D88F8E /* Main.storyboard */; }; 14 | 05D114191C41F22C00EF50D5 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D114181C41F22C00EF50D5 /* AppDelegate.swift */; }; 15 | 05D114201C41F22C00EF50D5 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 05D1141F1C41F22C00EF50D5 /* Assets.xcassets */; }; 16 | 05D1144C1C41F34900EF50D5 /* ImageCollectionViewCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D1144B1C41F34900EF50D5 /* ImageCollectionViewCell.swift */; }; 17 | 05D1144E1C41F3CD00EF50D5 /* ImageCollectionViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D1144D1C41F3CD00EF50D5 /* ImageCollectionViewController.swift */; }; 18 | 05D114501C41F43600EF50D5 /* ImagePickerViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 05D1144F1C41F43600EF50D5 /* ImagePickerViewController.swift */; }; 19 | /* End PBXBuildFile section */ 20 | 21 | /* Begin PBXFileReference section */ 22 | 052DD50E1C47B74000D88F8E /* ChopChop.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChopChop.swift; sourceTree = ""; }; 23 | 052DD5121C47B8A000D88F8E /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | 052DD5151C47B90C00D88F8E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 25 | 052DD5171C47B90C00D88F8E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 26 | 05D114151C41F22C00EF50D5 /* ChopChop.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ChopChop.app; sourceTree = BUILT_PRODUCTS_DIR; }; 27 | 05D114181C41F22C00EF50D5 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 28 | 05D1141F1C41F22C00EF50D5 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 29 | 05D1144B1C41F34900EF50D5 /* ImageCollectionViewCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCollectionViewCell.swift; sourceTree = ""; }; 30 | 05D1144D1C41F3CD00EF50D5 /* ImageCollectionViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageCollectionViewController.swift; sourceTree = ""; }; 31 | 05D1144F1C41F43600EF50D5 /* ImagePickerViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImagePickerViewController.swift; sourceTree = ""; }; 32 | /* End PBXFileReference section */ 33 | 34 | /* Begin PBXFrameworksBuildPhase section */ 35 | 05D114121C41F22C00EF50D5 /* Frameworks */ = { 36 | isa = PBXFrameworksBuildPhase; 37 | buildActionMask = 2147483647; 38 | files = ( 39 | ); 40 | runOnlyForDeploymentPostprocessing = 0; 41 | }; 42 | /* End PBXFrameworksBuildPhase section */ 43 | 44 | /* Begin PBXGroup section */ 45 | 05D1140C1C41F22C00EF50D5 = { 46 | isa = PBXGroup; 47 | children = ( 48 | 05D114171C41F22C00EF50D5 /* ChopChop */, 49 | 05D114161C41F22C00EF50D5 /* Products */, 50 | ); 51 | sourceTree = ""; 52 | }; 53 | 05D114161C41F22C00EF50D5 /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | 05D114151C41F22C00EF50D5 /* ChopChop.app */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | 05D114171C41F22C00EF50D5 /* ChopChop */ = { 62 | isa = PBXGroup; 63 | children = ( 64 | 05D114461C41F24B00EF50D5 /* ChopChopSrc */, 65 | 052DD5141C47B90C00D88F8E /* LaunchScreen.storyboard */, 66 | 052DD5161C47B90C00D88F8E /* Main.storyboard */, 67 | 05D114181C41F22C00EF50D5 /* AppDelegate.swift */, 68 | 05D1144F1C41F43600EF50D5 /* ImagePickerViewController.swift */, 69 | 05D1141F1C41F22C00EF50D5 /* Assets.xcassets */, 70 | 05D1144B1C41F34900EF50D5 /* ImageCollectionViewCell.swift */, 71 | 05D1144D1C41F3CD00EF50D5 /* ImageCollectionViewController.swift */, 72 | 052DD5121C47B8A000D88F8E /* Info.plist */, 73 | ); 74 | path = ChopChop; 75 | sourceTree = ""; 76 | }; 77 | 05D114461C41F24B00EF50D5 /* ChopChopSrc */ = { 78 | isa = PBXGroup; 79 | children = ( 80 | 052DD50E1C47B74000D88F8E /* ChopChop.swift */, 81 | ); 82 | name = ChopChopSrc; 83 | path = ChopChop; 84 | sourceTree = ""; 85 | }; 86 | /* End PBXGroup section */ 87 | 88 | /* Begin PBXNativeTarget section */ 89 | 05D114141C41F22C00EF50D5 /* ChopChop */ = { 90 | isa = PBXNativeTarget; 91 | buildConfigurationList = 05D1143D1C41F22C00EF50D5 /* Build configuration list for PBXNativeTarget "ChopChop" */; 92 | buildPhases = ( 93 | 05D114111C41F22C00EF50D5 /* Sources */, 94 | 05D114121C41F22C00EF50D5 /* Frameworks */, 95 | 05D114131C41F22C00EF50D5 /* Resources */, 96 | ); 97 | buildRules = ( 98 | ); 99 | dependencies = ( 100 | ); 101 | name = ChopChop; 102 | productName = PKImageMatrixCropper; 103 | productReference = 05D114151C41F22C00EF50D5 /* ChopChop.app */; 104 | productType = "com.apple.product-type.application"; 105 | }; 106 | /* End PBXNativeTarget section */ 107 | 108 | /* Begin PBXProject section */ 109 | 05D1140D1C41F22C00EF50D5 /* Project object */ = { 110 | isa = PBXProject; 111 | attributes = { 112 | LastSwiftUpdateCheck = 0720; 113 | LastUpgradeCheck = 0720; 114 | ORGANIZATIONNAME = "Pavan Kataria"; 115 | TargetAttributes = { 116 | 05D114141C41F22C00EF50D5 = { 117 | CreatedOnToolsVersion = 7.2; 118 | }; 119 | }; 120 | }; 121 | buildConfigurationList = 05D114101C41F22C00EF50D5 /* Build configuration list for PBXProject "ChopChop" */; 122 | compatibilityVersion = "Xcode 3.2"; 123 | developmentRegion = English; 124 | hasScannedForEncodings = 0; 125 | knownRegions = ( 126 | en, 127 | Base, 128 | ); 129 | mainGroup = 05D1140C1C41F22C00EF50D5; 130 | productRefGroup = 05D114161C41F22C00EF50D5 /* Products */; 131 | projectDirPath = ""; 132 | projectRoot = ""; 133 | targets = ( 134 | 05D114141C41F22C00EF50D5 /* ChopChop */, 135 | ); 136 | }; 137 | /* End PBXProject section */ 138 | 139 | /* Begin PBXResourcesBuildPhase section */ 140 | 05D114131C41F22C00EF50D5 /* Resources */ = { 141 | isa = PBXResourcesBuildPhase; 142 | buildActionMask = 2147483647; 143 | files = ( 144 | 052DD5181C47B90C00D88F8E /* LaunchScreen.storyboard in Resources */, 145 | 052DD5131C47B8A000D88F8E /* Info.plist in Resources */, 146 | 05D114201C41F22C00EF50D5 /* Assets.xcassets in Resources */, 147 | 052DD5191C47B90C00D88F8E /* Main.storyboard in Resources */, 148 | ); 149 | runOnlyForDeploymentPostprocessing = 0; 150 | }; 151 | /* End PBXResourcesBuildPhase section */ 152 | 153 | /* Begin PBXSourcesBuildPhase section */ 154 | 05D114111C41F22C00EF50D5 /* Sources */ = { 155 | isa = PBXSourcesBuildPhase; 156 | buildActionMask = 2147483647; 157 | files = ( 158 | 05D114501C41F43600EF50D5 /* ImagePickerViewController.swift in Sources */, 159 | 05D114191C41F22C00EF50D5 /* AppDelegate.swift in Sources */, 160 | 052DD50F1C47B74000D88F8E /* ChopChop.swift in Sources */, 161 | 05D1144C1C41F34900EF50D5 /* ImageCollectionViewCell.swift in Sources */, 162 | 05D1144E1C41F3CD00EF50D5 /* ImageCollectionViewController.swift in Sources */, 163 | ); 164 | runOnlyForDeploymentPostprocessing = 0; 165 | }; 166 | /* End PBXSourcesBuildPhase section */ 167 | 168 | /* Begin PBXVariantGroup section */ 169 | 052DD5141C47B90C00D88F8E /* LaunchScreen.storyboard */ = { 170 | isa = PBXVariantGroup; 171 | children = ( 172 | 052DD5151C47B90C00D88F8E /* Base */, 173 | ); 174 | name = LaunchScreen.storyboard; 175 | sourceTree = ""; 176 | }; 177 | 052DD5161C47B90C00D88F8E /* Main.storyboard */ = { 178 | isa = PBXVariantGroup; 179 | children = ( 180 | 052DD5171C47B90C00D88F8E /* Base */, 181 | ); 182 | name = Main.storyboard; 183 | sourceTree = ""; 184 | }; 185 | /* End PBXVariantGroup section */ 186 | 187 | /* Begin XCBuildConfiguration section */ 188 | 05D1143B1C41F22C00EF50D5 /* Debug */ = { 189 | isa = XCBuildConfiguration; 190 | buildSettings = { 191 | ALWAYS_SEARCH_USER_PATHS = NO; 192 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 193 | CLANG_CXX_LIBRARY = "libc++"; 194 | CLANG_ENABLE_MODULES = YES; 195 | CLANG_ENABLE_OBJC_ARC = YES; 196 | CLANG_WARN_BOOL_CONVERSION = YES; 197 | CLANG_WARN_CONSTANT_CONVERSION = YES; 198 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 199 | CLANG_WARN_EMPTY_BODY = YES; 200 | CLANG_WARN_ENUM_CONVERSION = YES; 201 | CLANG_WARN_INT_CONVERSION = YES; 202 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 203 | CLANG_WARN_UNREACHABLE_CODE = YES; 204 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 205 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 206 | COPY_PHASE_STRIP = NO; 207 | DEBUG_INFORMATION_FORMAT = dwarf; 208 | ENABLE_STRICT_OBJC_MSGSEND = YES; 209 | ENABLE_TESTABILITY = YES; 210 | GCC_C_LANGUAGE_STANDARD = gnu99; 211 | GCC_DYNAMIC_NO_PIC = NO; 212 | GCC_NO_COMMON_BLOCKS = YES; 213 | GCC_OPTIMIZATION_LEVEL = 0; 214 | GCC_PREPROCESSOR_DEFINITIONS = ( 215 | "DEBUG=1", 216 | "$(inherited)", 217 | ); 218 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 219 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 220 | GCC_WARN_UNDECLARED_SELECTOR = YES; 221 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 222 | GCC_WARN_UNUSED_FUNCTION = YES; 223 | GCC_WARN_UNUSED_VARIABLE = YES; 224 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 225 | MTL_ENABLE_DEBUG_INFO = YES; 226 | ONLY_ACTIVE_ARCH = YES; 227 | SDKROOT = iphoneos; 228 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 229 | TARGETED_DEVICE_FAMILY = "1,2"; 230 | }; 231 | name = Debug; 232 | }; 233 | 05D1143C1C41F22C00EF50D5 /* Release */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ALWAYS_SEARCH_USER_PATHS = NO; 237 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 238 | CLANG_CXX_LIBRARY = "libc++"; 239 | CLANG_ENABLE_MODULES = YES; 240 | CLANG_ENABLE_OBJC_ARC = YES; 241 | CLANG_WARN_BOOL_CONVERSION = YES; 242 | CLANG_WARN_CONSTANT_CONVERSION = YES; 243 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 244 | CLANG_WARN_EMPTY_BODY = YES; 245 | CLANG_WARN_ENUM_CONVERSION = YES; 246 | CLANG_WARN_INT_CONVERSION = YES; 247 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 248 | CLANG_WARN_UNREACHABLE_CODE = YES; 249 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 250 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 251 | COPY_PHASE_STRIP = NO; 252 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 253 | ENABLE_NS_ASSERTIONS = NO; 254 | ENABLE_STRICT_OBJC_MSGSEND = YES; 255 | GCC_C_LANGUAGE_STANDARD = gnu99; 256 | GCC_NO_COMMON_BLOCKS = YES; 257 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 258 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 259 | GCC_WARN_UNDECLARED_SELECTOR = YES; 260 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 261 | GCC_WARN_UNUSED_FUNCTION = YES; 262 | GCC_WARN_UNUSED_VARIABLE = YES; 263 | IPHONEOS_DEPLOYMENT_TARGET = 9.2; 264 | MTL_ENABLE_DEBUG_INFO = NO; 265 | SDKROOT = iphoneos; 266 | TARGETED_DEVICE_FAMILY = "1,2"; 267 | VALIDATE_PRODUCT = YES; 268 | }; 269 | name = Release; 270 | }; 271 | 05D1143E1C41F22C00EF50D5 /* Debug */ = { 272 | isa = XCBuildConfiguration; 273 | buildSettings = { 274 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 275 | INFOPLIST_FILE = ChopChop/Info.plist; 276 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 277 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 278 | PRODUCT_BUNDLE_IDENTIFIER = com.pavankataria.ChopChop; 279 | PRODUCT_NAME = ChopChop; 280 | }; 281 | name = Debug; 282 | }; 283 | 05D1143F1C41F22C00EF50D5 /* Release */ = { 284 | isa = XCBuildConfiguration; 285 | buildSettings = { 286 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 287 | INFOPLIST_FILE = ChopChop/Info.plist; 288 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 289 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 290 | PRODUCT_BUNDLE_IDENTIFIER = com.pavankataria.ChopChop; 291 | PRODUCT_NAME = ChopChop; 292 | }; 293 | name = Release; 294 | }; 295 | /* End XCBuildConfiguration section */ 296 | 297 | /* Begin XCConfigurationList section */ 298 | 05D114101C41F22C00EF50D5 /* Build configuration list for PBXProject "ChopChop" */ = { 299 | isa = XCConfigurationList; 300 | buildConfigurations = ( 301 | 05D1143B1C41F22C00EF50D5 /* Debug */, 302 | 05D1143C1C41F22C00EF50D5 /* Release */, 303 | ); 304 | defaultConfigurationIsVisible = 0; 305 | defaultConfigurationName = Release; 306 | }; 307 | 05D1143D1C41F22C00EF50D5 /* Build configuration list for PBXNativeTarget "ChopChop" */ = { 308 | isa = XCConfigurationList; 309 | buildConfigurations = ( 310 | 05D1143E1C41F22C00EF50D5 /* Debug */, 311 | 05D1143F1C41F22C00EF50D5 /* Release */, 312 | ); 313 | defaultConfigurationIsVisible = 0; 314 | defaultConfigurationName = Release; 315 | }; 316 | /* End XCConfigurationList section */ 317 | }; 318 | rootObject = 05D1140D1C41F22C00EF50D5 /* Project object */; 319 | } 320 | -------------------------------------------------------------------------------- /Demo/ChopChop/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 46 | 56 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | --------------------------------------------------------------------------------