├── CollectionPickerView ├── Assets │ └── .gitkeep └── Classes │ ├── .gitkeep │ ├── CollectionPickerViewFlowLayout.swift │ └── CollectionPickerView.swift ├── _Pods.xcodeproj ├── Screenshot.gif ├── Example ├── CollectionPickerView.xcodeproj │ ├── project.xcworkspace │ │ └── contents.xcworkspacedata │ └── project.pbxproj ├── Podfile ├── CollectionPickerView.xcworkspace │ └── contents.xcworkspacedata ├── Podfile.lock ├── .gitignore ├── Tests │ ├── Info.plist │ └── Tests.swift └── CollectionPickerView │ ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Info.plist │ ├── AppDelegate.swift │ ├── Base.lproj │ ├── Main.storyboard │ └── LaunchScreen.xib │ └── ViewController.swift ├── Package.swift ├── .travis.yml ├── .gitignore ├── LICENSE ├── CollectionPickerView.podspec ├── README.md └── Sources └── CollectionPickerView ├── CollectionPickerViewFlowLayout.swift └── CollectionPickerView.swift /CollectionPickerView/Assets/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CollectionPickerView/Classes/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /_Pods.xcodeproj: -------------------------------------------------------------------------------- 1 | Example/Pods/Pods.xcodeproj -------------------------------------------------------------------------------- /Screenshot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/3ph/CollectionPickerView/HEAD/Screenshot.gif -------------------------------------------------------------------------------- /Example/CollectionPickerView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Example/Podfile: -------------------------------------------------------------------------------- 1 | use_frameworks! 2 | platform :ios, '8.3' 3 | 4 | target 'CollectionPickerView_Example' do 5 | pod 'CollectionPickerView', :path => '../' 6 | 7 | target 'CollectionPickerView_Tests' do 8 | inherit! :search_paths 9 | 10 | pod 'Quick', '~> 2.1.0' 11 | pod 'Nimble', '~> 8.0.1' 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /Example/CollectionPickerView.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.3 2 | // The swift-tools-version declares the minimum version of Swift required to build this package. 3 | 4 | import PackageDescription 5 | 6 | let package = Package( 7 | name: "CollectionPickerView", 8 | products: [ 9 | .library(name: "CollectionPickerView", targets: ["CollectionPickerView"]), 10 | ], 11 | targets: [ 12 | .target(name: "CollectionPickerView") 13 | ] 14 | ) 15 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | # references: 2 | # * http://www.objc.io/issue-6/travis-ci.html 3 | # * https://github.com/supermarin/xcpretty#usage 4 | 5 | osx_image: xcode10.2 6 | language: objective-c 7 | cache: cocoapods 8 | podfile: Example/Podfile 9 | before_install: 10 | - gem install cocoapods # Since Travis is not always on latest version 11 | - pod install --project-directory=Example --repo-update 12 | script: 13 | - set -o pipefail && xcodebuild -workspace Example/CollectionPickerView.xcworkspace -scheme CollectionPickerView_Example ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator | xcpretty 14 | - pod lib lint --no-clean --allow-warnings 15 | -------------------------------------------------------------------------------- /Example/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - CollectionPickerView (0.1.2) 3 | - Nimble (8.0.1) 4 | - Quick (2.1.0) 5 | 6 | DEPENDENCIES: 7 | - CollectionPickerView (from `../`) 8 | - Nimble (~> 8.0.1) 9 | - Quick (~> 2.1.0) 10 | 11 | SPEC REPOS: 12 | https://github.com/cocoapods/specs.git: 13 | - Nimble 14 | - Quick 15 | 16 | EXTERNAL SOURCES: 17 | CollectionPickerView: 18 | :path: "../" 19 | 20 | SPEC CHECKSUMS: 21 | CollectionPickerView: fd5c85a5e542c9d55ef9f849b34cb9f68a36e611 22 | Nimble: 45f786ae66faa9a709624227fae502db55a8bdd0 23 | Quick: 4be43f6634acfa727dd106bdf3929ce125ffa79d 24 | 25 | PODFILE CHECKSUM: 2e3253d6f4953f2045cde284a9479ab7ae08415e 26 | 27 | COCOAPODS: 1.6.1 28 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | *.xccheckout 16 | profile 17 | *.moved-aside 18 | DerivedData 19 | *.hmap 20 | *.ipa 21 | 22 | # Bundler 23 | .bundle 24 | 25 | Carthage 26 | # We recommend against adding the Pods directory to your .gitignore. However 27 | # you should judge for yourself, the pros and cons are mentioned at: 28 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 29 | # 30 | # Note: if you ignore the Pods directory, make sure to uncomment 31 | # `pod install` in .travis.yml 32 | # 33 | Pods/ 34 | -------------------------------------------------------------------------------- /Example/.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | .DS_Store 3 | 4 | # Xcode 5 | build/ 6 | *.pbxuser 7 | !default.pbxuser 8 | *.mode1v3 9 | !default.mode1v3 10 | *.mode2v3 11 | !default.mode2v3 12 | *.perspectivev3 13 | !default.perspectivev3 14 | xcuserdata/ 15 | xcshareddata/ 16 | *.xccheckout 17 | profile 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | 23 | # Bundler 24 | .bundle 25 | 26 | Carthage 27 | # We recommend against adding the Pods directory to your .gitignore. However 28 | # you should judge for yourself, the pros and cons are mentioned at: 29 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 30 | # 31 | # Note: if you ignore the Pods directory, make sure to uncomment 32 | # `pod install` in .travis.yml 33 | # 34 | Pods/ 35 | -------------------------------------------------------------------------------- /Example/Tests/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 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2017 3ph 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is 8 | furnished to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in 11 | all copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /Example/CollectionPickerView/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | }, 43 | { 44 | "idiom" : "ios-marketing", 45 | "size" : "1024x1024", 46 | "scale" : "1x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /Example/CollectionPickerView/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 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /Example/Tests/Tests.swift: -------------------------------------------------------------------------------- 1 | // https://github.com/Quick/Quick 2 | 3 | import Quick 4 | import Nimble 5 | import CollectionPickerView 6 | 7 | class TableOfContentsSpec: QuickSpec { 8 | override func spec() { 9 | describe("these will fail") { 10 | 11 | /* 12 | 13 | it("can do maths") { 14 | expect(1) == 2 15 | } 16 | 17 | it("can read") { 18 | expect("number") == "string" 19 | } 20 | 21 | it("will eventually fail") { 22 | expect("time").toEventually( equal("done") ) 23 | } 24 | */ 25 | 26 | context("these will pass") { 27 | 28 | it("can do maths") { 29 | expect(23) == 23 30 | } 31 | 32 | it("can read") { 33 | expect("🐮") == "🐮" 34 | } 35 | 36 | it("will eventually pass") { 37 | var time = "passing" 38 | 39 | DispatchQueue.main.async { 40 | time = "done" 41 | } 42 | 43 | waitUntil { done in 44 | Thread.sleep(forTimeInterval: 0.5) 45 | expect(time) == "done" 46 | 47 | done() 48 | } 49 | } 50 | } 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /CollectionPickerView.podspec: -------------------------------------------------------------------------------- 1 | # 2 | # Be sure to run `pod lib lint CollectionPickerView.podspec' to ensure this is a 3 | # valid spec before submitting. 4 | # 5 | # Any lines starting with a # are optional, but their use is encouraged 6 | # To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html 7 | # 8 | 9 | Pod::Spec.new do |s| 10 | s.name = 'CollectionPickerView' 11 | s.version = '0.1.2' 12 | s.summary = 'A generic customizable picker view based on UICollectionView.' 13 | 14 | s.description = <<-DESC 15 | Generic and customizable picker based on UICollectionView. Picker cells are fully 16 | customizable. Supports flat/wheel look, snap to center after scroll, horizontal 17 | and vertical direction. 18 | 19 | Fork of AKPickerView-Swift. Works in iOS 8. 20 | DESC 21 | 22 | s.homepage = 'https://github.com/3ph/CollectionPickerView' 23 | # s.screenshots = 'www.example.com/screenshots_1', 'www.example.com/screenshots_2' 24 | s.license = { :type => 'MIT', :file => 'LICENSE' } 25 | s.author = { '3ph' => 'instantni.med@gmail.com' } 26 | s.source = { :git => 'https://github.com/3ph/CollectionPickerView.git', :tag => s.version.to_s } 27 | # s.social_media_url = 'https://twitter.com/' 28 | s.swift_version = '4.2' 29 | 30 | s.ios.deployment_target = '8.0' 31 | 32 | s.source_files = 'CollectionPickerView/Classes/**/*' 33 | s.pod_target_xcconfig = { 'SWIFT_VERSION' => '4.0' } 34 | end 35 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # CollectionPickerView 2 | 3 | [![CI Status](http://img.shields.io/travis/3ph/CollectionPickerView.svg?style=flat)](https://travis-ci.org/3ph/CollectionPickerView) 4 | [![Version](https://img.shields.io/cocoapods/v/CollectionPickerView.svg?style=flat)](http://cocoapods.org/pods/CollectionPickerView) 5 | [![License](https://img.shields.io/cocoapods/l/CollectionPickerView.svg?style=flat)](http://cocoapods.org/pods/CollectionPickerView) 6 | [![Platform](https://img.shields.io/cocoapods/p/CollectionPickerView.svg?style=flat)](http://cocoapods.org/pods/CollectionPickerView) 7 | ![Swift](https://img.shields.io/badge/in-swift5-orange.svg) 8 | 9 | 10 | Generic and customizable picker based on UICollectionView. Picker cells are fully 11 | customizable. 12 | 13 | Supports: 14 | - Flat/wheel look. 15 | - Snap to center after scroll. 16 | - Both horizontal and vertical direction. 17 | 18 | Fork of AKPickerView-Swift. Works in iOS 8. 19 | 20 | Screenshot 21 | 22 | ## Usage 23 | 24 | Since this view is using `UICollectionView` internally you have to provide data same way as you would do with collection view (using dataSource). You can also use delegate if you want to handle item selection or underlaying UIScrollView callbacks. See example project for details. 25 | 26 | Set the direction to vertical. 27 | ```swift 28 | pickerView.isHorizontal = false 29 | ``` 30 | 31 | Disable wheel effect of the picker. 32 | ```swift 33 | pickerView.isFlat = true 34 | ``` 35 | 36 | Prevent center selection when scrolling. 37 | ```swift 38 | pickerView.selectCenter = false 39 | ``` 40 | 41 | Set spacing between cells, default 10. 42 | ```swift 43 | pickerView.cellSpacing = 10 44 | ``` 45 | 46 | Set cell size (width for horizontal, height for vertical style), default 100. 47 | ```swift 48 | pickerView.cellSize = 100 49 | ``` 50 | 51 | Set wheel effect perspective representation. 52 | ```swift 53 | pickerView.viewDepth = 2000 54 | ``` 55 | 56 | Disable fading gradient mask. 57 | ```swift 58 | pickerView.maskDisabled = true 59 | ``` 60 | 61 | Current selected index might be obtained from `selectedIndex`. 62 | ```swift 63 | NSLog("\(pickerView.selectedIndex)") 64 | ``` 65 | 66 | And reload the picker view when any change in data set occurs. 67 | ```swift 68 | pickerView.reloadData() 69 | ``` 70 | 71 | 72 | 73 | ## Example 74 | 75 | To run the example project, clone the repo, and run `pod install` from the Example directory first. Or simplest way is just to run `pod try`. 76 | 77 | ## Installation 78 | 79 | CollectionPickerView is available through [CocoaPods](http://cocoapods.org). To install 80 | it, simply add the following line to your Podfile: 81 | 82 | ```ruby 83 | pod "CollectionPickerView" 84 | ``` 85 | 86 | ## Author 87 | 88 | Tomas Friml, instantni.med@gmail.com 89 | 90 | ## License 91 | 92 | CollectionPickerView is available under the MIT license. See the LICENSE file for more info. 93 | -------------------------------------------------------------------------------- /Example/CollectionPickerView/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // CollectionPickerView 4 | // 5 | // The MIT License (MIT) 6 | // 7 | // Copyright (c) 2015 Akkyie Y, 2017 Tomas Friml 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE 26 | 27 | import UIKit 28 | 29 | @UIApplicationMain 30 | class AppDelegate: UIResponder, UIApplicationDelegate { 31 | 32 | var window: UIWindow? 33 | 34 | 35 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 36 | // Override point for customization after application launch. 37 | return true 38 | } 39 | 40 | func applicationWillResignActive(_ application: UIApplication) { 41 | // 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. 42 | // 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. 43 | } 44 | 45 | func applicationDidEnterBackground(_ application: UIApplication) { 46 | // 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. 47 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 48 | } 49 | 50 | func applicationWillEnterForeground(_ application: UIApplication) { 51 | // 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. 52 | } 53 | 54 | func applicationDidBecomeActive(_ application: UIApplication) { 55 | // 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. 56 | } 57 | 58 | func applicationWillTerminate(_ application: UIApplication) { 59 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 60 | } 61 | 62 | 63 | } 64 | 65 | -------------------------------------------------------------------------------- /Example/CollectionPickerView/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 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Example/CollectionPickerView/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /Example/CollectionPickerView/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // CollectionPickerView 4 | // 5 | // The MIT License (MIT) 6 | // 7 | // Copyright (c) 2015 Akkyie Y, 2017 Tomas Friml 8 | // 9 | // Permission is hereby granted, free of charge, to any person obtaining a copy 10 | // of this software and associated documentation files (the "Software"), to deal 11 | // in the Software without restriction, including without limitation the rights 12 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 13 | // copies of the Software, and to permit persons to whom the Software is 14 | // furnished to do so, subject to the following conditions: 15 | // 16 | // The above copyright notice and this permission notice shall be included in all 17 | // copies or substantial portions of the Software. 18 | // 19 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 22 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 24 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 25 | // SOFTWARE 26 | 27 | import UIKit 28 | import CollectionPickerView 29 | 30 | class ViewController: UIViewController { 31 | 32 | @IBOutlet weak var pickerView: CollectionPickerView! 33 | 34 | let titles = ["Tokyo", "Kanagawa", "Osaka", "Aichi", "Saitama", "Chiba", "Hyogo", "Hokkaido", "Fukuoka", "Shizuoka"] 35 | 36 | let font = UIFont(name: "HelveticaNeue-Light", size: 20)! 37 | let highlightedFont = UIFont(name: "HelveticaNeue", size: 20)! 38 | 39 | override func viewDidLoad() { 40 | super.viewDidLoad() 41 | 42 | pickerView.dataSource = self 43 | pickerView.delegate = self 44 | 45 | pickerView.collectionView.reloadData() 46 | pickerView.collectionView.register( 47 | CollectionPickerViewCell.self, 48 | forCellWithReuseIdentifier: NSStringFromClass(CollectionPickerViewCell.self)) 49 | 50 | // Uncomment to have vertical direction 51 | //pickerView.isHorizontal = false 52 | 53 | // Uncomment to remove wheel effect 54 | //pickerView.isFlat = true 55 | 56 | // Uncomment to prevent selection on scroll 57 | //pickerView.selectCenter = false 58 | 59 | // Uncomment to set spacing between cells, default 10 60 | //pickerView.cellSpacing = 10 61 | 62 | // Uncomment to set cell size (width for horizontal, height for vertical style), default 100 63 | //pickerView.cellSize = 100 64 | 65 | // Uncomment to set wheel effect perspective representation 66 | //pickerView.viewDepth = 2000 67 | 68 | // Uncomment to enable/disable fading gradient mask 69 | //pickerView.maskDisabled = false 70 | 71 | // Current selected index might be obtained from selectedIndex 72 | //NSLog("\(pickerView.selectedIndex)") 73 | 74 | // Reload the picker view 75 | pickerView.reloadData() 76 | } 77 | 78 | fileprivate func sizeForString(_ string: NSString) -> CGSize { 79 | let size = string.size(withAttributes: [NSAttributedString.Key.font: self.font]) 80 | let highlightedSize = string.size(withAttributes: [NSAttributedString.Key.font: self.highlightedFont]) 81 | return CGSize( 82 | width: ceil(max(size.width, highlightedSize.width)), 83 | height: ceil(max(size.height, highlightedSize.height))) 84 | } 85 | } 86 | 87 | extension ViewController: UICollectionViewDelegate { 88 | /* 89 | 90 | UIScrollViewDelegate/UICollectionViewDelegate Support 91 | ---------------------------- 92 | AKPickerViewDelegate inherits UIScroll(Collection)ViewDelegate. 93 | You can use UIScroll(Collection)ViewDelegate methods 94 | by simply setting pickerView's delegate. 95 | 96 | */ 97 | 98 | func scrollViewDidScroll(_ scrollView: UIScrollView) { 99 | //NSLog("SCROLL: \(scrollView.contentOffset.x)") 100 | } 101 | 102 | func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 103 | let index = indexPath.item 104 | 105 | NSLog("Selected item: \(titles[index])") 106 | } 107 | } 108 | 109 | // MARK: UICollectionViewDataSource 110 | extension ViewController: UICollectionViewDataSource { 111 | public func numberOfSections(in collectionView: UICollectionView) -> Int { 112 | return 1 113 | } 114 | 115 | public func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int { 116 | return titles.count 117 | } 118 | 119 | public func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell { 120 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: NSStringFromClass(CollectionPickerViewCell.self), for: indexPath) as! CollectionPickerViewCell 121 | let title = titles[indexPath.item] 122 | 123 | cell.label.text = title 124 | cell.label.font = font 125 | cell.font = font 126 | cell.highlightedFont = highlightedFont 127 | cell.label.bounds = CGRect(origin: CGPoint.zero, size: sizeForString(title as NSString)) 128 | return cell 129 | } 130 | } 131 | 132 | 133 | private class CollectionPickerViewCell: UICollectionViewCell { 134 | var label: UILabel! 135 | var imageView: UIImageView! 136 | var font = UIFont.systemFont(ofSize: UIFont.systemFontSize) 137 | var highlightedFont = UIFont.systemFont(ofSize: UIFont.systemFontSize) 138 | override var isSelected: Bool { 139 | didSet { 140 | let animation = CATransition() 141 | animation.type = CATransitionType.fade 142 | animation.duration = 0.15 143 | self.label.layer.add(animation, forKey: "") 144 | self.label.font = self.isSelected ? self.highlightedFont : self.font 145 | } 146 | } 147 | 148 | func initialize() { 149 | self.layer.isDoubleSided = false 150 | self.layer.shouldRasterize = true 151 | self.layer.rasterizationScale = UIScreen.main.scale 152 | 153 | self.label = UILabel(frame: self.contentView.bounds) 154 | self.label.backgroundColor = UIColor.clear 155 | self.label.textAlignment = .center 156 | self.label.textColor = UIColor.gray 157 | self.label.numberOfLines = 1 158 | self.label.lineBreakMode = .byTruncatingTail 159 | self.label.highlightedTextColor = UIColor.black 160 | self.label.font = self.font 161 | self.label.autoresizingMask = [.flexibleTopMargin, .flexibleLeftMargin, .flexibleBottomMargin, .flexibleRightMargin] 162 | self.contentView.addSubview(self.label) 163 | 164 | self.imageView = UIImageView(frame: self.contentView.bounds) 165 | self.imageView.backgroundColor = UIColor.clear 166 | self.imageView.contentMode = .center 167 | self.imageView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 168 | self.contentView.addSubview(self.imageView) 169 | } 170 | 171 | init() { 172 | super.init(frame: CGRect.zero) 173 | self.initialize() 174 | } 175 | 176 | override init(frame: CGRect) { 177 | super.init(frame: frame) 178 | self.initialize() 179 | } 180 | 181 | required init!(coder aDecoder: NSCoder) { 182 | super.init(coder: aDecoder) 183 | self.initialize() 184 | } 185 | } 186 | 187 | -------------------------------------------------------------------------------- /Sources/CollectionPickerView/CollectionPickerViewFlowLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionPickerFlowLayout.swift 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Copyright (c) 2015 Akkyie Y, 2017 Tomas Friml 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE 25 | 26 | import UIKit 27 | 28 | public class CollectionPickerViewFlowLayout: UICollectionViewFlowLayout { 29 | 30 | open var maxAngle : CGFloat = CGFloat.pi / 2 31 | open var isFlat : Bool = true 32 | 33 | fileprivate var _isHorizontal : Bool { 34 | get { 35 | return scrollDirection == .horizontal 36 | } 37 | } 38 | fileprivate var _halfDim : CGFloat { 39 | get { 40 | return (_isHorizontal ? _visibleRect.width : _visibleRect.height) / 2 41 | } 42 | } 43 | fileprivate var _mid : CGFloat { 44 | get { 45 | return _isHorizontal ? _visibleRect.midX : _visibleRect.midY 46 | } 47 | } 48 | fileprivate var _visibleRect : CGRect { 49 | get { 50 | if let cv = collectionView { 51 | return CGRect(origin: cv.contentOffset, size: cv.bounds.size) 52 | } 53 | return CGRect.zero 54 | } 55 | } 56 | 57 | func initialize() { 58 | sectionInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0) 59 | minimumLineSpacing = 0.0 60 | } 61 | 62 | override init() { 63 | super.init() 64 | self.initialize() 65 | } 66 | 67 | required public init?(coder aDecoder: NSCoder) { 68 | super.init(coder: aDecoder) 69 | self.initialize() 70 | } 71 | 72 | public override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { 73 | return true 74 | } 75 | 76 | public override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { 77 | if let attributes = super.layoutAttributesForItem(at: indexPath)?.copy() as? UICollectionViewLayoutAttributes { 78 | if isFlat == false { 79 | let distance = (_isHorizontal ? attributes.frame.midX : attributes.frame.midY) - _mid 80 | let currentAngle = maxAngle * distance / _halfDim / (CGFloat.pi / 2) 81 | var transform = CATransform3DIdentity 82 | if _isHorizontal { 83 | transform = CATransform3DTranslate(transform, -distance, 0, -_halfDim) 84 | transform = CATransform3DRotate(transform, currentAngle, 0, 1, 0) 85 | } else { 86 | transform = CATransform3DTranslate(transform, 0, distance, -_halfDim) 87 | transform = CATransform3DRotate(transform, currentAngle, 1, 0, 0) 88 | } 89 | transform = CATransform3DTranslate(transform, 0, 0, _halfDim) 90 | attributes.transform3D = transform 91 | attributes.alpha = abs(currentAngle) < maxAngle ? 1.0 : 0.0 92 | return attributes; 93 | } 94 | return attributes 95 | } 96 | 97 | return nil 98 | } 99 | 100 | public override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 101 | if isFlat == false { 102 | var attributes = [UICollectionViewLayoutAttributes]() 103 | if self.collectionView!.numberOfSections > 0 { 104 | for i in 0 ..< self.collectionView!.numberOfItems(inSection: 0) { 105 | let indexPath = IndexPath(item: i, section: 0) 106 | attributes.append(self.layoutAttributesForItem(at: indexPath)!) 107 | } 108 | } 109 | return attributes 110 | } 111 | return super.layoutAttributesForElements(in: rect) 112 | } 113 | 114 | // public override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { 115 | // guard let cv = collectionView else { return CGPoint.zero } 116 | // 117 | // let dim = _isHorizontal ? cv.bounds.width : cv.bounds.height 118 | // let halfDim = dim / 2 119 | // var offsetAdjustment: CGFloat = CGFloat.greatestFiniteMagnitude 120 | // var selectedCenter: CGFloat = dim 121 | // 122 | // let center: CGFloat = _isHorizontal ? proposedContentOffset.x + halfDim : proposedContentOffset.y + halfDim 123 | // let targetRect = CGRect(x: _isHorizontal ? proposedContentOffset.x : 0, y: _isHorizontal ? 0 : proposedContentOffset.y, width: cv.bounds.size.width, height: cv.bounds.size.height) 124 | // let array:[UICollectionViewLayoutAttributes] = layoutAttributesForElements(in: targetRect)! 125 | // for layoutAttributes: UICollectionViewLayoutAttributes in array { 126 | // let itemCenter: CGFloat = _isHorizontal ? layoutAttributes.center.x : layoutAttributes.center.y 127 | // if abs(itemCenter - center) < abs(offsetAdjustment) { 128 | // offsetAdjustment = itemCenter - center 129 | // selectedCenter = itemCenter 130 | // NSLog("PropX: \(proposedContentOffset.x), offset: \(offsetAdjustment), itemCenter: \(itemCenter), center: \(center)") 131 | // } 132 | // } 133 | // return CGPoint(x: proposedContentOffset.x - (_isHorizontal ? offsetAdjustment : 0), y: proposedContentOffset.y + (_isHorizontal ? 0 : offsetAdjustment)) 134 | // } 135 | 136 | var snapToCenter : Bool = true 137 | 138 | var mostRecentOffset : CGPoint = CGPoint() 139 | 140 | public override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { 141 | // _ = scrollDirection == .horizontal 142 | // 143 | // if snapToCenter == false { 144 | // return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity) 145 | // } 146 | // guard let collectionView = collectionView else { return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity) } 147 | // 148 | // var offsetAdjustment = CGFloat.greatestFiniteMagnitude 149 | // let offset = isHorizontal ? proposedContentOffset.x + collectionView.contentInset.left : proposedContentOffset.y + collectionView.contentInset.top 150 | // 151 | // let targetRect : CGRect 152 | // if isHorizontal { 153 | // targetRect = CGRect(x: proposedContentOffset.x, y: 0, width: collectionView.bounds.size.width, height: collectionView.bounds.size.height) 154 | // } else { 155 | // targetRect = CGRect(x: 0, y: proposedContentOffset.y, width: collectionView.bounds.size.width, height: collectionView.bounds.size.height) 156 | // } 157 | // 158 | // let layoutAttributesArray = super.layoutAttributesForElements(in: targetRect) 159 | // 160 | // layoutAttributesArray?.forEach({ (layoutAttributes) in 161 | // let itemOffset = isHorizontal ? layoutAttributes.frame.origin.x : layoutAttributes.frame.origin.y 162 | // if fabsf(Float(itemOffset - offset)) < fabsf(Float(offsetAdjustment)) { 163 | // offsetAdjustment = itemOffset - offset 164 | // } 165 | // }) 166 | // 167 | // if (isHorizontal && velocity.x == 0) || (isHorizontal == false && velocity.y == 0) { 168 | // return mostRecentOffset 169 | // } 170 | // 171 | // if let cv = self.collectionView { 172 | // 173 | // let cvBounds = cv.bounds 174 | // let half = (isHorizontal ? cvBounds.size.width : cvBounds.size.height) * 0.5; 175 | // 176 | // if let attributesForVisibleCells = self.layoutAttributesForElements(in: cvBounds) { 177 | // 178 | // var candidateAttributes : UICollectionViewLayoutAttributes? 179 | // for attributes in attributesForVisibleCells { 180 | // 181 | // // == Skip comparison with non-cell items (headers and footers) == // 182 | // if attributes.representedElementCategory != UICollectionElementCategory.cell { 183 | // continue 184 | // } 185 | // 186 | // if isHorizontal { 187 | // if attributes.center.x == 0 || (attributes.center.x > (cv.contentOffset.x + half) && velocity.x < 0) { 188 | // continue 189 | // } 190 | // } else { 191 | // if attributes.center.y == 0 || (attributes.center.y > (cv.contentOffset.y + half) && velocity.y < 0) { 192 | // continue 193 | // } 194 | // } 195 | // 196 | // candidateAttributes = attributes 197 | // } 198 | // 199 | // // Beautification step , I don't know why it works! 200 | // if (isHorizontal && proposedContentOffset.x == -cv.contentInset.left) 201 | // || (isHorizontal == false && proposedContentOffset.y == -cv.contentInset.top) { 202 | // return proposedContentOffset 203 | // } 204 | // 205 | // guard let _ = candidateAttributes else { 206 | // return mostRecentOffset 207 | // } 208 | // 209 | // if isHorizontal { 210 | // mostRecentOffset = CGPoint(x: floor(candidateAttributes!.center.x - half), y: proposedContentOffset.y) 211 | // } else { 212 | // mostRecentOffset = CGPoint(x: proposedContentOffset.y, y: floor(candidateAttributes!.center.y - half)) 213 | // } 214 | // 215 | // return mostRecentOffset 216 | // } 217 | // } 218 | 219 | // fallback 220 | mostRecentOffset = super.targetContentOffset(forProposedContentOffset: proposedContentOffset) 221 | return mostRecentOffset 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /CollectionPickerView/Classes/CollectionPickerViewFlowLayout.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionPickerFlowLayout.swift 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Copyright (c) 2015 Akkyie Y, 2017 Tomas Friml 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE 25 | 26 | import UIKit 27 | 28 | public class CollectionPickerViewFlowLayout: UICollectionViewFlowLayout { 29 | 30 | open var maxAngle : CGFloat = CGFloat.pi / 2 31 | open var isFlat : Bool = true 32 | 33 | fileprivate var _isHorizontal : Bool { 34 | get { 35 | return scrollDirection == .horizontal 36 | } 37 | } 38 | fileprivate var _halfDim : CGFloat { 39 | get { 40 | return (_isHorizontal ? _visibleRect.width : _visibleRect.height) / 2 41 | } 42 | } 43 | fileprivate var _mid : CGFloat { 44 | get { 45 | return _isHorizontal ? _visibleRect.midX : _visibleRect.midY 46 | } 47 | } 48 | fileprivate var _visibleRect : CGRect { 49 | get { 50 | if let cv = collectionView { 51 | return CGRect(origin: cv.contentOffset, size: cv.bounds.size) 52 | } 53 | return CGRect.zero 54 | } 55 | } 56 | 57 | func initialize() { 58 | sectionInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: 0.0, right: 0.0) 59 | minimumLineSpacing = 0.0 60 | } 61 | 62 | override init() { 63 | super.init() 64 | self.initialize() 65 | } 66 | 67 | required public init?(coder aDecoder: NSCoder) { 68 | super.init(coder: aDecoder) 69 | self.initialize() 70 | } 71 | 72 | public override func shouldInvalidateLayout(forBoundsChange newBounds: CGRect) -> Bool { 73 | return true 74 | } 75 | 76 | public override func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? { 77 | if let attributes = super.layoutAttributesForItem(at: indexPath)?.copy() as? UICollectionViewLayoutAttributes { 78 | if isFlat == false { 79 | let distance = _isHorizontal ? (attributes.frame.midX - _mid) : (_mid - attributes.frame.midY) 80 | let currentAngle = maxAngle * distance / _halfDim / (CGFloat.pi / 2) 81 | var transform = CATransform3DIdentity 82 | if _isHorizontal { 83 | transform = CATransform3DTranslate(transform, -distance, 0, -_halfDim) 84 | transform = CATransform3DRotate(transform, currentAngle, 0, 1, 0) 85 | } else { 86 | transform = CATransform3DTranslate(transform, 0, distance, -_halfDim) 87 | transform = CATransform3DRotate(transform, currentAngle, 1, 0, 0) 88 | } 89 | transform = CATransform3DTranslate(transform, 0, 0, _halfDim) 90 | attributes.transform3D = transform 91 | attributes.alpha = abs(currentAngle) < maxAngle ? 1.0 : 0.0 92 | return attributes; 93 | } 94 | return attributes 95 | } 96 | 97 | return nil 98 | } 99 | 100 | public override func layoutAttributesForElements(in rect: CGRect) -> [UICollectionViewLayoutAttributes]? { 101 | if isFlat == false { 102 | var attributes = [UICollectionViewLayoutAttributes]() 103 | if self.collectionView!.numberOfSections > 0 { 104 | for i in 0 ..< self.collectionView!.numberOfItems(inSection: 0) { 105 | let indexPath = IndexPath(item: i, section: 0) 106 | attributes.append(self.layoutAttributesForItem(at: indexPath)!) 107 | } 108 | } 109 | return attributes 110 | } 111 | return super.layoutAttributesForElements(in: rect) 112 | } 113 | 114 | // public override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { 115 | // guard let cv = collectionView else { return CGPoint.zero } 116 | // 117 | // let dim = _isHorizontal ? cv.bounds.width : cv.bounds.height 118 | // let halfDim = dim / 2 119 | // var offsetAdjustment: CGFloat = CGFloat.greatestFiniteMagnitude 120 | // var selectedCenter: CGFloat = dim 121 | // 122 | // let center: CGFloat = _isHorizontal ? proposedContentOffset.x + halfDim : proposedContentOffset.y + halfDim 123 | // let targetRect = CGRect(x: _isHorizontal ? proposedContentOffset.x : 0, y: _isHorizontal ? 0 : proposedContentOffset.y, width: cv.bounds.size.width, height: cv.bounds.size.height) 124 | // let array:[UICollectionViewLayoutAttributes] = layoutAttributesForElements(in: targetRect)! 125 | // for layoutAttributes: UICollectionViewLayoutAttributes in array { 126 | // let itemCenter: CGFloat = _isHorizontal ? layoutAttributes.center.x : layoutAttributes.center.y 127 | // if abs(itemCenter - center) < abs(offsetAdjustment) { 128 | // offsetAdjustment = itemCenter - center 129 | // selectedCenter = itemCenter 130 | // NSLog("PropX: \(proposedContentOffset.x), offset: \(offsetAdjustment), itemCenter: \(itemCenter), center: \(center)") 131 | // } 132 | // } 133 | // return CGPoint(x: proposedContentOffset.x - (_isHorizontal ? offsetAdjustment : 0), y: proposedContentOffset.y + (_isHorizontal ? 0 : offsetAdjustment)) 134 | // } 135 | 136 | var snapToCenter : Bool = true 137 | 138 | var mostRecentOffset : CGPoint = CGPoint() 139 | 140 | public override func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint { 141 | // _ = scrollDirection == .horizontal 142 | // 143 | // if snapToCenter == false { 144 | // return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity) 145 | // } 146 | // guard let collectionView = collectionView else { return super.targetContentOffset(forProposedContentOffset: proposedContentOffset, withScrollingVelocity: velocity) } 147 | // 148 | // var offsetAdjustment = CGFloat.greatestFiniteMagnitude 149 | // let offset = isHorizontal ? proposedContentOffset.x + collectionView.contentInset.left : proposedContentOffset.y + collectionView.contentInset.top 150 | // 151 | // let targetRect : CGRect 152 | // if isHorizontal { 153 | // targetRect = CGRect(x: proposedContentOffset.x, y: 0, width: collectionView.bounds.size.width, height: collectionView.bounds.size.height) 154 | // } else { 155 | // targetRect = CGRect(x: 0, y: proposedContentOffset.y, width: collectionView.bounds.size.width, height: collectionView.bounds.size.height) 156 | // } 157 | // 158 | // let layoutAttributesArray = super.layoutAttributesForElements(in: targetRect) 159 | // 160 | // layoutAttributesArray?.forEach({ (layoutAttributes) in 161 | // let itemOffset = isHorizontal ? layoutAttributes.frame.origin.x : layoutAttributes.frame.origin.y 162 | // if fabsf(Float(itemOffset - offset)) < fabsf(Float(offsetAdjustment)) { 163 | // offsetAdjustment = itemOffset - offset 164 | // } 165 | // }) 166 | // 167 | // if (isHorizontal && velocity.x == 0) || (isHorizontal == false && velocity.y == 0) { 168 | // return mostRecentOffset 169 | // } 170 | // 171 | // if let cv = self.collectionView { 172 | // 173 | // let cvBounds = cv.bounds 174 | // let half = (isHorizontal ? cvBounds.size.width : cvBounds.size.height) * 0.5; 175 | // 176 | // if let attributesForVisibleCells = self.layoutAttributesForElements(in: cvBounds) { 177 | // 178 | // var candidateAttributes : UICollectionViewLayoutAttributes? 179 | // for attributes in attributesForVisibleCells { 180 | // 181 | // // == Skip comparison with non-cell items (headers and footers) == // 182 | // if attributes.representedElementCategory != UICollectionElementCategory.cell { 183 | // continue 184 | // } 185 | // 186 | // if isHorizontal { 187 | // if attributes.center.x == 0 || (attributes.center.x > (cv.contentOffset.x + half) && velocity.x < 0) { 188 | // continue 189 | // } 190 | // } else { 191 | // if attributes.center.y == 0 || (attributes.center.y > (cv.contentOffset.y + half) && velocity.y < 0) { 192 | // continue 193 | // } 194 | // } 195 | // 196 | // candidateAttributes = attributes 197 | // } 198 | // 199 | // // Beautification step , I don't know why it works! 200 | // if (isHorizontal && proposedContentOffset.x == -cv.contentInset.left) 201 | // || (isHorizontal == false && proposedContentOffset.y == -cv.contentInset.top) { 202 | // return proposedContentOffset 203 | // } 204 | // 205 | // guard let _ = candidateAttributes else { 206 | // return mostRecentOffset 207 | // } 208 | // 209 | // if isHorizontal { 210 | // mostRecentOffset = CGPoint(x: floor(candidateAttributes!.center.x - half), y: proposedContentOffset.y) 211 | // } else { 212 | // mostRecentOffset = CGPoint(x: proposedContentOffset.y, y: floor(candidateAttributes!.center.y - half)) 213 | // } 214 | // 215 | // return mostRecentOffset 216 | // } 217 | // } 218 | 219 | // fallback 220 | mostRecentOffset = super.targetContentOffset(forProposedContentOffset: proposedContentOffset) 221 | return mostRecentOffset 222 | } 223 | } 224 | -------------------------------------------------------------------------------- /CollectionPickerView/Classes/CollectionPickerView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionPickerView.swift 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Copyright (c) 2015 Akkyie Y, 2017 Tomas Friml 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE 25 | // 26 | 27 | import UIKit 28 | 29 | 30 | /// Allows user to override collection view delegate methods 31 | public class CollectionPickerViewForwardDelegate: NSObject, UICollectionViewDelegate { 32 | 33 | init(picker: CollectionPickerView) { 34 | _picker = picker 35 | } 36 | internal weak var delegate : UICollectionViewDelegate? 37 | 38 | // MARK: - Private 39 | fileprivate weak var _picker : CollectionPickerView? 40 | 41 | override public func forwardingTarget(for aSelector: Selector!) -> Any? { 42 | if let p = _picker, p.responds(to: aSelector) { 43 | return p 44 | } else if let d = delegate, d.responds(to: aSelector) { 45 | return d 46 | } 47 | return super.responds(to: aSelector) 48 | } 49 | 50 | override public func responds(to aSelector: Selector!) -> Bool { 51 | if let p = _picker, p.responds(to: aSelector) { 52 | return true 53 | } else if let d = delegate, d.responds(to: aSelector) { 54 | return true 55 | } 56 | return super.responds(to: aSelector) 57 | } 58 | 59 | } 60 | 61 | 62 | public class CollectionPickerView: UIView { 63 | 64 | 65 | public let collectionView : UICollectionView 66 | 67 | /// Readwrite. Spacing between cells 68 | @IBInspectable public var cellSpacing : CGFloat = 10 69 | 70 | /// Readwrite. Default cell size (based on direction of picker) 71 | @IBInspectable public var cellSize : CGFloat = 100 72 | 73 | /// Readwrite. Select center item on scroll 74 | @IBInspectable public var selectCenter : Bool = true 75 | 76 | /// Readwrite. Determines style of the picker 77 | @IBInspectable public var isFlat : Bool = false { 78 | didSet { 79 | didSetIsFlat() 80 | } 81 | } 82 | 83 | /// Readwrite. Picker direction 84 | @IBInspectable public var isHorizontal : Bool = true { 85 | didSet { 86 | didSetFlowLayoutDirection() 87 | didSetMaskDisabled() 88 | } 89 | } 90 | 91 | /// Readwrite. A float value which determines the perspective representation which used when using wheel style. 92 | @IBInspectable public var viewDepth: CGFloat = 2000 { 93 | didSet { 94 | didSetViewDepth() 95 | } 96 | } 97 | 98 | /// Readwrite. A boolean value indicates whether the mask is disabled. 99 | @IBInspectable public var maskDisabled: Bool = false { 100 | didSet { 101 | didSetMaskDisabled() 102 | } 103 | } 104 | 105 | /// Readonly. Currently selected collection view item index 106 | public private(set) var selectedIndex : Int = 0 107 | 108 | public weak var dataSource : UICollectionViewDataSource? { 109 | didSet { 110 | collectionView.dataSource = dataSource 111 | } 112 | } 113 | public weak var delegate : UICollectionViewDelegate? { 114 | didSet { 115 | _forwardDelegate.delegate = delegate 116 | } 117 | } 118 | 119 | public override var intrinsicContentSize : CGSize { 120 | // TODO: figure out max. 121 | if isHorizontal { 122 | return CGSize(width: UIView.noIntrinsicMetric, height: cellSize) 123 | } else { 124 | return CGSize(width: cellSize, height: UIView.noIntrinsicMetric) 125 | } 126 | } 127 | 128 | 129 | override init(frame: CGRect) { 130 | collectionView = UICollectionView(frame: frame, collectionViewLayout: CollectionPickerViewFlowLayout()) 131 | super.init(frame: frame) 132 | 133 | initialize() 134 | } 135 | 136 | convenience init() { 137 | self.init(frame: CGRect.zero) 138 | } 139 | 140 | required public init?(coder aDecoder: NSCoder) { 141 | collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: CollectionPickerViewFlowLayout()) 142 | super.init(coder: aDecoder) 143 | 144 | initialize() 145 | } 146 | 147 | /** 148 | Select a cell whose index is given one and move to it. 149 | :param: index An integer value which indicates the index of cell. 150 | :param: animated True if the scrolling should be animated, false if it should be immediate. 151 | */ 152 | public func selectItem(at index: Int, animated: Bool = false) { 153 | self.selectItem(at: index, animated: animated, scroll: true, notifySelection: true) 154 | } 155 | 156 | /** 157 | Reload the picker view's contents and styles. Call this method always after any property is changed. 158 | */ 159 | public func reloadData() { 160 | invalidateIntrinsicContentSize() 161 | collectionView.collectionViewLayout.invalidateLayout() 162 | collectionView.reloadData() 163 | if collectionView.numberOfItems(inSection: 0) > 0 { 164 | selectItem(at: selectedIndex, animated: false) 165 | } 166 | } 167 | 168 | // MARK: - Private 169 | fileprivate var _flowLayout : CollectionPickerViewFlowLayout? { 170 | get { 171 | return collectionView.collectionViewLayout as? CollectionPickerViewFlowLayout 172 | } 173 | } 174 | fileprivate var _forwardDelegate : CollectionPickerViewForwardDelegate! 175 | 176 | fileprivate func initialize() { 177 | addSubview(collectionView) 178 | 179 | _forwardDelegate = CollectionPickerViewForwardDelegate(picker: self) 180 | 181 | collectionView.delegate = _forwardDelegate 182 | collectionView.isScrollEnabled = true 183 | collectionView.showsHorizontalScrollIndicator = false 184 | collectionView.showsVerticalScrollIndicator = false 185 | collectionView.decelerationRate = UIScrollView.DecelerationRate.fast 186 | collectionView.backgroundColor = UIColor.clear 187 | collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 188 | 189 | // have to call didSets separatele as it's not being invoked for initial values 190 | didSetFlowLayoutDirection() 191 | didSetIsFlat() 192 | didSetMaskDisabled() 193 | didSetViewDepth() 194 | } 195 | 196 | 197 | /** 198 | Private. Used to calculate the x-coordinate of the content offset of specified item. 199 | :param: item An integer value which indicates the index of cell. 200 | :returns: An x/y-coordinate of the cell whose index is given one. 201 | */ 202 | fileprivate func offsetForItem(at index: Int) -> CGFloat { 203 | let firstIndexPath = IndexPath(item: 0, section: 0) 204 | let firstSize = self.collectionView( 205 | collectionView, 206 | layout: collectionView.collectionViewLayout, 207 | sizeForItemAt: firstIndexPath) 208 | var offset: CGFloat = isHorizontal 209 | ? collectionView.bounds.width / 2 - firstSize.width / 4 210 | : collectionView.bounds.height / 2 - firstSize.height / 4 211 | for i in 0 ..< index { 212 | let indexPath = IndexPath(item: i, section: 0) 213 | let cellSize = self.collectionView( 214 | collectionView, 215 | layout: collectionView.collectionViewLayout, 216 | sizeForItemAt: indexPath) 217 | offset += (isHorizontal ? cellSize.width : cellSize.height) + cellSpacing 218 | } 219 | 220 | let selectedIndexPath = IndexPath(item: index, section: 0) 221 | let selectedSize = self.collectionView( 222 | collectionView, 223 | layout: collectionView.collectionViewLayout, 224 | sizeForItemAt: selectedIndexPath) 225 | if isHorizontal { 226 | offset -= collectionView.bounds.width / 2 - selectedSize.width / 2 227 | } else { 228 | offset -= collectionView.bounds.height / 2 - selectedSize.height / 2 229 | } 230 | 231 | return offset 232 | } 233 | 234 | /** 235 | Move to the cell whose index is given one without selection change. 236 | :param: index An integer value which indicates the index of cell. 237 | :param: animated True if the scrolling should be animated, false if it should be immediate. 238 | */ 239 | fileprivate func scrollToItem(at index: Int, animated: Bool = false) { 240 | if isFlat { 241 | collectionView.scrollToItem( 242 | at: IndexPath( 243 | item: index, 244 | section: 0), 245 | at: isHorizontal ? .centeredHorizontally : .centeredVertically, 246 | animated: animated) 247 | } else { 248 | collectionView.setContentOffset( 249 | CGPoint( 250 | x: isHorizontal ? offsetForItem(at: index) : collectionView.contentOffset.x, 251 | y: isHorizontal ? collectionView.contentOffset.y : offsetForItem(at: index)), 252 | animated: animated) 253 | } 254 | } 255 | 256 | /** 257 | Private. Select a cell whose index is given one and move to it, with specifying whether it calls delegate method. 258 | :param: index An integer value which indicates the index of cell. 259 | :param: animated True if the scrolling should be animated, false if it should be immediate. 260 | :param: notifySelection True if the delegate method should be called, false if not. 261 | */ 262 | fileprivate func selectItem(at index: Int, animated: Bool, scroll: Bool, notifySelection: Bool) { 263 | /* 264 | let oldIndexPath = IndexPath(item: selectedIndex, section: 0) 265 | let newIndexPath = IndexPath(item: index, section: 0) 266 | */ 267 | let indexPath = IndexPath(item: index, section: 0) 268 | collectionView.selectItem( 269 | at: indexPath, 270 | animated: animated, 271 | scrollPosition: UICollectionView.ScrollPosition()) 272 | if scroll { 273 | scrollToItem(at: index, animated: animated) 274 | } 275 | 276 | selectedIndex = index 277 | self.delegate?.collectionView?(collectionView, didSelectItemAt: indexPath) 278 | 279 | /* 280 | selectedItem = item 281 | */ 282 | } 283 | 284 | 285 | fileprivate func didSetFlowLayoutDirection() { 286 | _flowLayout?.scrollDirection = isHorizontal ? .horizontal : .vertical 287 | _flowLayout?.invalidateLayout() 288 | } 289 | 290 | fileprivate func didSetIsFlat() { 291 | _flowLayout?.isFlat = isFlat 292 | } 293 | 294 | fileprivate func didSetMaskDisabled() { 295 | collectionView.layer.mask = maskDisabled == true ? nil : { 296 | let maskLayer = CAGradientLayer() 297 | maskLayer.frame = collectionView.bounds 298 | maskLayer.colors = [ 299 | UIColor.clear.cgColor, 300 | UIColor.black.cgColor, 301 | UIColor.black.cgColor, 302 | UIColor.clear.cgColor] 303 | maskLayer.locations = [0.0, 0.33, 0.66, 1.0] 304 | maskLayer.startPoint = CGPoint(x: 0.0, y: 0.0) 305 | if isHorizontal { 306 | maskLayer.endPoint = CGPoint(x: 1.0, y: 0.0) 307 | } else { 308 | maskLayer.endPoint = CGPoint(x: 0.0, y: 1.0) 309 | } 310 | return maskLayer 311 | }() 312 | } 313 | 314 | fileprivate func didSetViewDepth() { 315 | collectionView.layer.sublayerTransform = viewDepth > 0.0 ? { 316 | var transform = CATransform3DIdentity; 317 | transform.m34 = -1.0 / viewDepth; 318 | return transform; 319 | }() : CATransform3DIdentity; 320 | } 321 | } 322 | 323 | // MARK: - UICollectionViewDelegate 324 | extension CollectionPickerView: UICollectionViewDelegate { 325 | public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 326 | selectItem(at: indexPath.item, animated: true) 327 | } 328 | } 329 | 330 | // MARK: - Layout 331 | extension CollectionPickerView { 332 | override public func layoutSubviews() { 333 | super.layoutSubviews() 334 | 335 | reloadData() 336 | 337 | collectionView.frame = collectionView.superview!.bounds 338 | collectionView.layer.mask?.frame = collectionView.bounds 339 | if collectionView.numberOfItems(inSection: 0) > 0 { 340 | selectItem(at: selectedIndex) 341 | } 342 | } 343 | } 344 | 345 | // MARK: - UIScrollViewDelegate 346 | extension CollectionPickerView : UIScrollViewDelegate { 347 | 348 | fileprivate func didScroll(end: Bool) { 349 | 350 | if isFlat { 351 | let center = convert(collectionView.center, to: collectionView) 352 | if let indexPath = collectionView.indexPathForItem(at: center) { 353 | self.selectItem(at: indexPath.item, animated: true, scroll: end, notifySelection: true) 354 | } 355 | } else { 356 | for i in 0 ..< collectionView.numberOfItems(inSection: 0) { 357 | let indexPath = IndexPath(item: i, section: 0) 358 | let cellSize = self.collectionView( 359 | collectionView, 360 | layout: collectionView.collectionViewLayout, 361 | sizeForItemAt: indexPath) 362 | if (isHorizontal && (offsetForItem(at: i) + cellSize.width / 2 > collectionView.contentOffset.x)) 363 | || (isHorizontal == false && (offsetForItem(at: i) + cellSize.height / 2 > collectionView.contentOffset.y)) { 364 | //if i != selectedIndex { 365 | selectItem(at: i, animated: true, scroll: end, notifySelection: true) 366 | //} 367 | break 368 | } 369 | } 370 | } 371 | } 372 | 373 | public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 374 | delegate?.scrollViewDidEndDecelerating?(scrollView) 375 | 376 | didScroll(end: true) 377 | } 378 | 379 | public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { 380 | delegate?.scrollViewDidEndDragging?(scrollView, willDecelerate: decelerate) 381 | 382 | if !decelerate { 383 | didScroll(end: true) 384 | } 385 | } 386 | 387 | public func scrollViewDidScroll(_ scrollView: UIScrollView) { 388 | delegate?.scrollViewDidScroll?(scrollView) 389 | 390 | CATransaction.begin() 391 | CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions) 392 | collectionView.layer.mask?.frame = collectionView.bounds 393 | CATransaction.commit() 394 | } 395 | } 396 | 397 | extension CollectionPickerView: UICollectionViewDelegateFlowLayout { 398 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { 399 | let number = collectionView.numberOfItems(inSection: section) 400 | let firstIndexPath = IndexPath(item: 0, section: section) 401 | let firstSize = self.collectionView(collectionView, layout: collectionViewLayout, sizeForItemAt: firstIndexPath) 402 | let lastIndexPath = IndexPath(item: number - 1, section: section) 403 | let lastSize = self.collectionView(collectionView, layout: collectionViewLayout, sizeForItemAt: lastIndexPath) 404 | if isHorizontal { 405 | return UIEdgeInsets( 406 | top: 0, left: (collectionView.bounds.size.width - firstSize.width/2) / 2, 407 | bottom: 0, right: (collectionView.bounds.size.width - lastSize.width/2) / 2 408 | ) 409 | } else { 410 | return UIEdgeInsets( 411 | top: (collectionView.bounds.size.height - firstSize.height/2) / 2, left: 0, 412 | bottom: (collectionView.bounds.size.height - lastSize.height/2) / 2, right: 0 413 | ) 414 | } 415 | } 416 | 417 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 418 | if isHorizontal { 419 | return CGSize(width: cellSize, height: collectionView.bounds.height) 420 | } else { 421 | return CGSize(width: collectionView.bounds.width, height: cellSize) 422 | } 423 | } 424 | 425 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { 426 | return 0 427 | } 428 | 429 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { 430 | return cellSpacing 431 | } 432 | } 433 | -------------------------------------------------------------------------------- /Sources/CollectionPickerView/CollectionPickerView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CollectionPickerView.swift 3 | // 4 | // The MIT License (MIT) 5 | // 6 | // Copyright (c) 2015 Akkyie Y, 2017 Tomas Friml 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in all 16 | // copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | // SOFTWARE 25 | // 26 | 27 | import UIKit 28 | 29 | 30 | /// Allows user to override collection view delegate methods 31 | public class CollectionPickerViewForwardDelegate: NSObject, UICollectionViewDelegate { 32 | 33 | init(picker: CollectionPickerView) { 34 | _picker = picker 35 | } 36 | internal weak var delegate : UICollectionViewDelegate? 37 | 38 | // MARK: - Private 39 | fileprivate weak var _picker : CollectionPickerView? 40 | 41 | override public func forwardingTarget(for aSelector: Selector!) -> Any? { 42 | if let p = _picker, p.responds(to: aSelector) { 43 | return p 44 | } else if let d = delegate, d.responds(to: aSelector) { 45 | return d 46 | } 47 | return super.responds(to: aSelector) 48 | } 49 | 50 | override public func responds(to aSelector: Selector!) -> Bool { 51 | if let p = _picker, p.responds(to: aSelector) { 52 | return true 53 | } else if let d = delegate, d.responds(to: aSelector) { 54 | return true 55 | } 56 | return super.responds(to: aSelector) 57 | } 58 | 59 | } 60 | 61 | 62 | public class CollectionPickerView: UIView { 63 | 64 | 65 | public let collectionView : UICollectionView 66 | 67 | /// Readwrite. Spacing between cells 68 | @IBInspectable public var cellSpacing : CGFloat = 10 69 | 70 | /// Readwrite. Default cell size (based on direction of picker) 71 | @IBInspectable public var cellSize : CGFloat = 100 72 | 73 | /// Readwrite. Select center item on scroll 74 | @IBInspectable public var selectCenter : Bool = true 75 | 76 | /// Readwrite. Determines style of the picker 77 | @IBInspectable public var isFlat : Bool = false { 78 | didSet { 79 | didSetIsFlat() 80 | } 81 | } 82 | 83 | /// Readwrite. Picker direction 84 | @IBInspectable public var isHorizontal : Bool = true { 85 | didSet { 86 | didSetFlowLayoutDirection() 87 | didSetMaskDisabled() 88 | } 89 | } 90 | 91 | /// Readwrite. A float value which determines the perspective representation which used when using wheel style. 92 | @IBInspectable public var viewDepth: CGFloat = 2000 { 93 | didSet { 94 | didSetViewDepth() 95 | } 96 | } 97 | 98 | /// Readwrite. A boolean value indicates whether the mask is disabled. 99 | @IBInspectable public var maskDisabled: Bool = false { 100 | didSet { 101 | didSetMaskDisabled() 102 | } 103 | } 104 | 105 | /// Readonly. Currently selected collection view item index 106 | public private(set) var selectedIndex : Int = 0 107 | 108 | public weak var dataSource : UICollectionViewDataSource? { 109 | didSet { 110 | collectionView.dataSource = dataSource 111 | } 112 | } 113 | public weak var delegate : UICollectionViewDelegate? { 114 | didSet { 115 | _forwardDelegate.delegate = delegate 116 | } 117 | } 118 | 119 | public override var intrinsicContentSize : CGSize { 120 | // TODO: figure out max. 121 | if isHorizontal { 122 | return CGSize(width: UIView.noIntrinsicMetric, height: cellSize) 123 | } else { 124 | return CGSize(width: cellSize, height: UIView.noIntrinsicMetric) 125 | } 126 | } 127 | 128 | 129 | override init(frame: CGRect) { 130 | collectionView = UICollectionView(frame: frame, collectionViewLayout: CollectionPickerViewFlowLayout()) 131 | super.init(frame: frame) 132 | 133 | initialize() 134 | } 135 | 136 | convenience init() { 137 | self.init(frame: CGRect.zero) 138 | } 139 | 140 | required public init?(coder aDecoder: NSCoder) { 141 | collectionView = UICollectionView(frame: CGRect.zero, collectionViewLayout: CollectionPickerViewFlowLayout()) 142 | super.init(coder: aDecoder) 143 | 144 | initialize() 145 | } 146 | 147 | /** 148 | Select a cell whose index is given one and move to it. 149 | :param: index An integer value which indicates the index of cell. 150 | :param: animated True if the scrolling should be animated, false if it should be immediate. 151 | */ 152 | public func selectItem(at index: Int, animated: Bool = false) { 153 | self.selectItem(at: index, animated: animated, scroll: true, notifySelection: true) 154 | } 155 | 156 | /** 157 | Reload the picker view's contents and styles. Call this method always after any property is changed. 158 | */ 159 | public func reloadData() { 160 | invalidateIntrinsicContentSize() 161 | collectionView.collectionViewLayout.invalidateLayout() 162 | collectionView.reloadData() 163 | if collectionView.numberOfItems(inSection: 0) > 0 { 164 | selectItem(at: selectedIndex, animated: false) 165 | } 166 | } 167 | 168 | // MARK: - Private 169 | fileprivate var _flowLayout : CollectionPickerViewFlowLayout? { 170 | get { 171 | return collectionView.collectionViewLayout as? CollectionPickerViewFlowLayout 172 | } 173 | } 174 | fileprivate var _forwardDelegate : CollectionPickerViewForwardDelegate! 175 | 176 | fileprivate func initialize() { 177 | addSubview(collectionView) 178 | 179 | _forwardDelegate = CollectionPickerViewForwardDelegate(picker: self) 180 | 181 | collectionView.delegate = _forwardDelegate 182 | collectionView.isScrollEnabled = true 183 | collectionView.showsHorizontalScrollIndicator = false 184 | collectionView.showsVerticalScrollIndicator = false 185 | collectionView.decelerationRate = UIScrollView.DecelerationRate.fast 186 | collectionView.backgroundColor = UIColor.clear 187 | collectionView.autoresizingMask = [.flexibleWidth, .flexibleHeight] 188 | 189 | // have to call didSets separatele as it's not being invoked for initial values 190 | didSetFlowLayoutDirection() 191 | didSetIsFlat() 192 | didSetMaskDisabled() 193 | didSetViewDepth() 194 | } 195 | 196 | 197 | /** 198 | Private. Used to calculate the x-coordinate of the content offset of specified item. 199 | :param: item An integer value which indicates the index of cell. 200 | :returns: An x/y-coordinate of the cell whose index is given one. 201 | */ 202 | fileprivate func offsetForItem(at index: Int) -> CGFloat { 203 | let firstIndexPath = IndexPath(item: 0, section: 0) 204 | let firstSize = self.collectionView( 205 | collectionView, 206 | layout: collectionView.collectionViewLayout, 207 | sizeForItemAt: firstIndexPath) 208 | var offset: CGFloat = isHorizontal 209 | ? collectionView.bounds.width / 2 - firstSize.width / 4 210 | : collectionView.bounds.height / 2 - firstSize.height / 4 211 | for i in 0 ..< index { 212 | let indexPath = IndexPath(item: i, section: 0) 213 | let cellSize = self.collectionView( 214 | collectionView, 215 | layout: collectionView.collectionViewLayout, 216 | sizeForItemAt: indexPath) 217 | offset += (isHorizontal ? cellSize.width : cellSize.height) + cellSpacing 218 | } 219 | 220 | let selectedIndexPath = IndexPath(item: index, section: 0) 221 | let selectedSize = self.collectionView( 222 | collectionView, 223 | layout: collectionView.collectionViewLayout, 224 | sizeForItemAt: selectedIndexPath) 225 | if isHorizontal { 226 | offset -= collectionView.bounds.width / 2 - selectedSize.width / 2 227 | } else { 228 | offset -= collectionView.bounds.height / 2 - selectedSize.height / 2 229 | } 230 | 231 | return offset 232 | } 233 | 234 | /** 235 | Move to the cell whose index is given one without selection change. 236 | :param: index An integer value which indicates the index of cell. 237 | :param: animated True if the scrolling should be animated, false if it should be immediate. 238 | */ 239 | fileprivate func scrollToItem(at index: Int, animated: Bool = false) { 240 | if isFlat { 241 | collectionView.scrollToItem( 242 | at: IndexPath( 243 | item: index, 244 | section: 0), 245 | at: isHorizontal ? .centeredHorizontally : .centeredVertically, 246 | animated: animated) 247 | } else { 248 | collectionView.setContentOffset( 249 | CGPoint( 250 | x: isHorizontal ? offsetForItem(at: index) : collectionView.contentOffset.x, 251 | y: isHorizontal ? collectionView.contentOffset.y : offsetForItem(at: index)), 252 | animated: animated) 253 | } 254 | } 255 | 256 | /** 257 | Private. Select a cell whose index is given one and move to it, with specifying whether it calls delegate method. 258 | :param: index An integer value which indicates the index of cell. 259 | :param: animated True if the scrolling should be animated, false if it should be immediate. 260 | :param: notifySelection True if the delegate method should be called, false if not. 261 | */ 262 | fileprivate func selectItem(at index: Int, animated: Bool, scroll: Bool, notifySelection: Bool) { 263 | /* 264 | let oldIndexPath = IndexPath(item: selectedIndex, section: 0) 265 | let newIndexPath = IndexPath(item: index, section: 0) 266 | */ 267 | let indexPath = IndexPath(item: index, section: 0) 268 | collectionView.selectItem( 269 | at: indexPath, 270 | animated: animated, 271 | scrollPosition: UICollectionView.ScrollPosition()) 272 | if scroll { 273 | scrollToItem(at: index, animated: animated) 274 | } 275 | 276 | selectedIndex = index 277 | self.delegate?.collectionView?(collectionView, didSelectItemAt: indexPath) 278 | 279 | /* 280 | selectedItem = item 281 | */ 282 | } 283 | 284 | 285 | fileprivate func didSetFlowLayoutDirection() { 286 | _flowLayout?.scrollDirection = isHorizontal ? .horizontal : .vertical 287 | _flowLayout?.invalidateLayout() 288 | } 289 | 290 | fileprivate func didSetIsFlat() { 291 | _flowLayout?.isFlat = isFlat 292 | } 293 | 294 | fileprivate func didSetMaskDisabled() { 295 | collectionView.layer.mask = maskDisabled == true ? nil : { 296 | let maskLayer = CAGradientLayer() 297 | maskLayer.frame = collectionView.bounds 298 | maskLayer.colors = [ 299 | UIColor.clear.cgColor, 300 | UIColor.black.cgColor, 301 | UIColor.black.cgColor, 302 | UIColor.clear.cgColor] 303 | maskLayer.locations = [0.0, 0.33, 0.66, 1.0] 304 | maskLayer.startPoint = CGPoint(x: 0.0, y: 0.0) 305 | if isHorizontal { 306 | maskLayer.endPoint = CGPoint(x: 1.0, y: 0.0) 307 | } else { 308 | maskLayer.endPoint = CGPoint(x: 0.0, y: 1.0) 309 | } 310 | return maskLayer 311 | }() 312 | } 313 | 314 | fileprivate func didSetViewDepth() { 315 | collectionView.layer.sublayerTransform = viewDepth > 0.0 ? { 316 | var transform = CATransform3DIdentity; 317 | transform.m34 = -1.0 / viewDepth; 318 | return transform; 319 | }() : CATransform3DIdentity; 320 | } 321 | } 322 | 323 | // MARK: - UICollectionViewDelegate 324 | extension CollectionPickerView: UICollectionViewDelegate { 325 | public func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { 326 | selectItem(at: indexPath.item, animated: true) 327 | } 328 | } 329 | 330 | // MARK: - Layout 331 | extension CollectionPickerView { 332 | override public func layoutSubviews() { 333 | super.layoutSubviews() 334 | 335 | reloadData() 336 | 337 | collectionView.frame = collectionView.superview!.bounds 338 | collectionView.layer.mask?.frame = collectionView.bounds 339 | if collectionView.numberOfItems(inSection: 0) > 0 { 340 | selectItem(at: selectedIndex) 341 | } 342 | } 343 | } 344 | 345 | // MARK: - UIScrollViewDelegate 346 | extension CollectionPickerView : UIScrollViewDelegate { 347 | 348 | fileprivate func didScroll(end: Bool) { 349 | 350 | if isFlat { 351 | let center = convert(collectionView.center, to: collectionView) 352 | if let indexPath = collectionView.indexPathForItem(at: center) { 353 | self.selectItem(at: indexPath.item, animated: true, scroll: end, notifySelection: true) 354 | } 355 | } else { 356 | for i in 0 ..< collectionView.numberOfItems(inSection: 0) { 357 | let indexPath = IndexPath(item: i, section: 0) 358 | let cellSize = self.collectionView( 359 | collectionView, 360 | layout: collectionView.collectionViewLayout, 361 | sizeForItemAt: indexPath) 362 | if (isHorizontal && (offsetForItem(at: i) + cellSize.width / 2 > collectionView.contentOffset.x)) 363 | || (isHorizontal == false && (offsetForItem(at: i) + cellSize.height / 2 > collectionView.contentOffset.y)) { 364 | //if i != selectedIndex { 365 | selectItem(at: i, animated: true, scroll: end, notifySelection: true) 366 | //} 367 | break 368 | } 369 | } 370 | } 371 | } 372 | 373 | public func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { 374 | delegate?.scrollViewDidEndDecelerating?(scrollView) 375 | 376 | didScroll(end: true) 377 | } 378 | 379 | public func scrollViewDidEndDragging(_ scrollView: UIScrollView, willDecelerate decelerate: Bool) { 380 | delegate?.scrollViewDidEndDragging?(scrollView, willDecelerate: decelerate) 381 | 382 | if !decelerate { 383 | didScroll(end: true) 384 | } 385 | } 386 | 387 | public func scrollViewDidScroll(_ scrollView: UIScrollView) { 388 | delegate?.scrollViewDidScroll?(scrollView) 389 | 390 | CATransaction.begin() 391 | CATransaction.setValue(kCFBooleanTrue, forKey: kCATransactionDisableActions) 392 | collectionView.layer.mask?.frame = collectionView.bounds 393 | CATransaction.commit() 394 | } 395 | } 396 | 397 | extension CollectionPickerView: UICollectionViewDelegateFlowLayout { 398 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets { 399 | let number = collectionView.numberOfItems(inSection: section) 400 | let firstIndexPath = IndexPath(item: 0, section: section) 401 | let firstSize = self.collectionView(collectionView, layout: collectionViewLayout, sizeForItemAt: firstIndexPath) 402 | let lastIndexPath = IndexPath(item: number - 1, section: section) 403 | let lastSize = self.collectionView(collectionView, layout: collectionViewLayout, sizeForItemAt: lastIndexPath) 404 | if isHorizontal { 405 | return UIEdgeInsets( 406 | top: 0, left: (collectionView.bounds.size.width - firstSize.width/2) / 2, 407 | bottom: 0, right: (collectionView.bounds.size.width - lastSize.width/2) / 2 408 | ) 409 | } else { 410 | return UIEdgeInsets( 411 | top: (collectionView.bounds.size.height - firstSize.height/2) / 2, left: 0, 412 | bottom: (collectionView.bounds.size.height - lastSize.height/2) / 2, right: 0 413 | ) 414 | } 415 | } 416 | 417 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { 418 | if isHorizontal { 419 | return CGSize(width: cellSize, height: collectionView.bounds.height) 420 | } else { 421 | return CGSize(width: collectionView.bounds.width, height: cellSize) 422 | } 423 | } 424 | 425 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat { 426 | return 0 427 | } 428 | 429 | public func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { 430 | return cellSpacing 431 | } 432 | } 433 | -------------------------------------------------------------------------------- /Example/CollectionPickerView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACD51AFB9204008FA782 /* AppDelegate.swift */; }; 11 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 607FACD91AFB9204008FA782 /* Main.storyboard */; }; 12 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; }; 13 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; }; 14 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; }; 15 | C3B186101EE6ACE30004DF38 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C3B1860F1EE6ACE30004DF38 /* ViewController.swift */; }; 16 | D65F5E8417B94E2DD672EC43 /* Pods_CollectionPickerView_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B96268DE731DAC423E1F4750 /* Pods_CollectionPickerView_Tests.framework */; }; 17 | E6669765E83F0D2473FA9E67 /* Pods_CollectionPickerView_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1EF30C56B5D300BB71ED35B3 /* Pods_CollectionPickerView_Example.framework */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXContainerItemProxy section */ 21 | 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */ = { 22 | isa = PBXContainerItemProxy; 23 | containerPortal = 607FACC81AFB9204008FA782 /* Project object */; 24 | proxyType = 1; 25 | remoteGlobalIDString = 607FACCF1AFB9204008FA782; 26 | remoteInfo = CollectionPickerView; 27 | }; 28 | /* End PBXContainerItemProxy section */ 29 | 30 | /* Begin PBXFileReference section */ 31 | 1EF30C56B5D300BB71ED35B3 /* Pods_CollectionPickerView_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CollectionPickerView_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 3722EB4DB29AA899A072941B /* CollectionPickerView.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = CollectionPickerView.podspec; path = ../CollectionPickerView.podspec; sourceTree = ""; }; 33 | 4FD1FB7AE40A631A08A1205C /* Pods-CollectionPickerView_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollectionPickerView_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-CollectionPickerView_Tests/Pods-CollectionPickerView_Tests.release.xcconfig"; sourceTree = ""; }; 34 | 607FACD01AFB9204008FA782 /* CollectionPickerView_Example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CollectionPickerView_Example.app; sourceTree = BUILT_PRODUCTS_DIR; }; 35 | 607FACD41AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 36 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 37 | 607FACDA1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 38 | 607FACDC1AFB9204008FA782 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 39 | 607FACDF1AFB9204008FA782 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 40 | 607FACE51AFB9204008FA782 /* CollectionPickerView_Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CollectionPickerView_Tests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 41 | 607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 42 | 607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; 43 | 75517E8F62F0662CADC9172C /* Pods-CollectionPickerView_Example.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollectionPickerView_Example.release.xcconfig"; path = "Pods/Target Support Files/Pods-CollectionPickerView_Example/Pods-CollectionPickerView_Example.release.xcconfig"; sourceTree = ""; }; 44 | 777EAAE174293FF0E1EC523E /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; 45 | B3E1659BE6FC14D7B267056A /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = ""; }; 46 | B96268DE731DAC423E1F4750 /* Pods_CollectionPickerView_Tests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_CollectionPickerView_Tests.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 47 | C3B1860F1EE6ACE30004DF38 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 48 | CF049FDC0AE1FE108336FE52 /* Pods-CollectionPickerView_Example.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollectionPickerView_Example.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CollectionPickerView_Example/Pods-CollectionPickerView_Example.debug.xcconfig"; sourceTree = ""; }; 49 | F0757E8364A029EF8A7CE988 /* Pods-CollectionPickerView_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-CollectionPickerView_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-CollectionPickerView_Tests/Pods-CollectionPickerView_Tests.debug.xcconfig"; sourceTree = ""; }; 50 | /* End PBXFileReference section */ 51 | 52 | /* Begin PBXFrameworksBuildPhase section */ 53 | 607FACCD1AFB9204008FA782 /* Frameworks */ = { 54 | isa = PBXFrameworksBuildPhase; 55 | buildActionMask = 2147483647; 56 | files = ( 57 | E6669765E83F0D2473FA9E67 /* Pods_CollectionPickerView_Example.framework in Frameworks */, 58 | ); 59 | runOnlyForDeploymentPostprocessing = 0; 60 | }; 61 | 607FACE21AFB9204008FA782 /* Frameworks */ = { 62 | isa = PBXFrameworksBuildPhase; 63 | buildActionMask = 2147483647; 64 | files = ( 65 | D65F5E8417B94E2DD672EC43 /* Pods_CollectionPickerView_Tests.framework in Frameworks */, 66 | ); 67 | runOnlyForDeploymentPostprocessing = 0; 68 | }; 69 | /* End PBXFrameworksBuildPhase section */ 70 | 71 | /* Begin PBXGroup section */ 72 | 607FACC71AFB9204008FA782 = { 73 | isa = PBXGroup; 74 | children = ( 75 | 607FACF51AFB993E008FA782 /* Podspec Metadata */, 76 | 607FACD21AFB9204008FA782 /* Example for CollectionPickerView */, 77 | 607FACE81AFB9204008FA782 /* Tests */, 78 | 607FACD11AFB9204008FA782 /* Products */, 79 | BF7C558C5B4792D7A090A45F /* Pods */, 80 | 7676459B507A3A6373E0B950 /* Frameworks */, 81 | ); 82 | sourceTree = ""; 83 | }; 84 | 607FACD11AFB9204008FA782 /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | 607FACD01AFB9204008FA782 /* CollectionPickerView_Example.app */, 88 | 607FACE51AFB9204008FA782 /* CollectionPickerView_Tests.xctest */, 89 | ); 90 | name = Products; 91 | sourceTree = ""; 92 | }; 93 | 607FACD21AFB9204008FA782 /* Example for CollectionPickerView */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 607FACD51AFB9204008FA782 /* AppDelegate.swift */, 97 | C3B1860F1EE6ACE30004DF38 /* ViewController.swift */, 98 | 607FACD91AFB9204008FA782 /* Main.storyboard */, 99 | 607FACDC1AFB9204008FA782 /* Images.xcassets */, 100 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */, 101 | 607FACD31AFB9204008FA782 /* Supporting Files */, 102 | ); 103 | name = "Example for CollectionPickerView"; 104 | path = CollectionPickerView; 105 | sourceTree = ""; 106 | }; 107 | 607FACD31AFB9204008FA782 /* Supporting Files */ = { 108 | isa = PBXGroup; 109 | children = ( 110 | 607FACD41AFB9204008FA782 /* Info.plist */, 111 | ); 112 | name = "Supporting Files"; 113 | sourceTree = ""; 114 | }; 115 | 607FACE81AFB9204008FA782 /* Tests */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 607FACEB1AFB9204008FA782 /* Tests.swift */, 119 | 607FACE91AFB9204008FA782 /* Supporting Files */, 120 | ); 121 | path = Tests; 122 | sourceTree = ""; 123 | }; 124 | 607FACE91AFB9204008FA782 /* Supporting Files */ = { 125 | isa = PBXGroup; 126 | children = ( 127 | 607FACEA1AFB9204008FA782 /* Info.plist */, 128 | ); 129 | name = "Supporting Files"; 130 | sourceTree = ""; 131 | }; 132 | 607FACF51AFB993E008FA782 /* Podspec Metadata */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 3722EB4DB29AA899A072941B /* CollectionPickerView.podspec */, 136 | 777EAAE174293FF0E1EC523E /* README.md */, 137 | B3E1659BE6FC14D7B267056A /* LICENSE */, 138 | ); 139 | name = "Podspec Metadata"; 140 | sourceTree = ""; 141 | }; 142 | 7676459B507A3A6373E0B950 /* Frameworks */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 1EF30C56B5D300BB71ED35B3 /* Pods_CollectionPickerView_Example.framework */, 146 | B96268DE731DAC423E1F4750 /* Pods_CollectionPickerView_Tests.framework */, 147 | ); 148 | name = Frameworks; 149 | sourceTree = ""; 150 | }; 151 | BF7C558C5B4792D7A090A45F /* Pods */ = { 152 | isa = PBXGroup; 153 | children = ( 154 | CF049FDC0AE1FE108336FE52 /* Pods-CollectionPickerView_Example.debug.xcconfig */, 155 | 75517E8F62F0662CADC9172C /* Pods-CollectionPickerView_Example.release.xcconfig */, 156 | F0757E8364A029EF8A7CE988 /* Pods-CollectionPickerView_Tests.debug.xcconfig */, 157 | 4FD1FB7AE40A631A08A1205C /* Pods-CollectionPickerView_Tests.release.xcconfig */, 158 | ); 159 | name = Pods; 160 | sourceTree = ""; 161 | }; 162 | /* End PBXGroup section */ 163 | 164 | /* Begin PBXNativeTarget section */ 165 | 607FACCF1AFB9204008FA782 /* CollectionPickerView_Example */ = { 166 | isa = PBXNativeTarget; 167 | buildConfigurationList = 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "CollectionPickerView_Example" */; 168 | buildPhases = ( 169 | 187071B2A180AFAD1CF2D3C9 /* [CP] Check Pods Manifest.lock */, 170 | 607FACCC1AFB9204008FA782 /* Sources */, 171 | 607FACCD1AFB9204008FA782 /* Frameworks */, 172 | 607FACCE1AFB9204008FA782 /* Resources */, 173 | 8B4FA2CA31C25FDD19E9544E /* [CP] Embed Pods Frameworks */, 174 | ); 175 | buildRules = ( 176 | ); 177 | dependencies = ( 178 | ); 179 | name = CollectionPickerView_Example; 180 | productName = CollectionPickerView; 181 | productReference = 607FACD01AFB9204008FA782 /* CollectionPickerView_Example.app */; 182 | productType = "com.apple.product-type.application"; 183 | }; 184 | 607FACE41AFB9204008FA782 /* CollectionPickerView_Tests */ = { 185 | isa = PBXNativeTarget; 186 | buildConfigurationList = 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "CollectionPickerView_Tests" */; 187 | buildPhases = ( 188 | DE7445E27A0075664CBF8962 /* [CP] Check Pods Manifest.lock */, 189 | 607FACE11AFB9204008FA782 /* Sources */, 190 | 607FACE21AFB9204008FA782 /* Frameworks */, 191 | 607FACE31AFB9204008FA782 /* Resources */, 192 | E79105D1937C0EE7E64C605E /* [CP] Embed Pods Frameworks */, 193 | ); 194 | buildRules = ( 195 | ); 196 | dependencies = ( 197 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */, 198 | ); 199 | name = CollectionPickerView_Tests; 200 | productName = Tests; 201 | productReference = 607FACE51AFB9204008FA782 /* CollectionPickerView_Tests.xctest */; 202 | productType = "com.apple.product-type.bundle.unit-test"; 203 | }; 204 | /* End PBXNativeTarget section */ 205 | 206 | /* Begin PBXProject section */ 207 | 607FACC81AFB9204008FA782 /* Project object */ = { 208 | isa = PBXProject; 209 | attributes = { 210 | LastSwiftUpdateCheck = 0720; 211 | LastUpgradeCheck = 1020; 212 | ORGANIZATIONNAME = CocoaPods; 213 | TargetAttributes = { 214 | 607FACCF1AFB9204008FA782 = { 215 | CreatedOnToolsVersion = 6.3.1; 216 | LastSwiftMigration = 1020; 217 | }; 218 | 607FACE41AFB9204008FA782 = { 219 | CreatedOnToolsVersion = 6.3.1; 220 | LastSwiftMigration = 1020; 221 | TestTargetID = 607FACCF1AFB9204008FA782; 222 | }; 223 | }; 224 | }; 225 | buildConfigurationList = 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "CollectionPickerView" */; 226 | compatibilityVersion = "Xcode 3.2"; 227 | developmentRegion = English; 228 | hasScannedForEncodings = 0; 229 | knownRegions = ( 230 | English, 231 | en, 232 | Base, 233 | ); 234 | mainGroup = 607FACC71AFB9204008FA782; 235 | productRefGroup = 607FACD11AFB9204008FA782 /* Products */; 236 | projectDirPath = ""; 237 | projectRoot = ""; 238 | targets = ( 239 | 607FACCF1AFB9204008FA782 /* CollectionPickerView_Example */, 240 | 607FACE41AFB9204008FA782 /* CollectionPickerView_Tests */, 241 | ); 242 | }; 243 | /* End PBXProject section */ 244 | 245 | /* Begin PBXResourcesBuildPhase section */ 246 | 607FACCE1AFB9204008FA782 /* Resources */ = { 247 | isa = PBXResourcesBuildPhase; 248 | buildActionMask = 2147483647; 249 | files = ( 250 | 607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */, 251 | 607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */, 252 | 607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */, 253 | ); 254 | runOnlyForDeploymentPostprocessing = 0; 255 | }; 256 | 607FACE31AFB9204008FA782 /* Resources */ = { 257 | isa = PBXResourcesBuildPhase; 258 | buildActionMask = 2147483647; 259 | files = ( 260 | ); 261 | runOnlyForDeploymentPostprocessing = 0; 262 | }; 263 | /* End PBXResourcesBuildPhase section */ 264 | 265 | /* Begin PBXShellScriptBuildPhase section */ 266 | 187071B2A180AFAD1CF2D3C9 /* [CP] Check Pods Manifest.lock */ = { 267 | isa = PBXShellScriptBuildPhase; 268 | buildActionMask = 2147483647; 269 | files = ( 270 | ); 271 | inputFileListPaths = ( 272 | ); 273 | inputPaths = ( 274 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 275 | "${PODS_ROOT}/Manifest.lock", 276 | ); 277 | name = "[CP] Check Pods Manifest.lock"; 278 | outputFileListPaths = ( 279 | ); 280 | outputPaths = ( 281 | "$(DERIVED_FILE_DIR)/Pods-CollectionPickerView_Example-checkManifestLockResult.txt", 282 | ); 283 | runOnlyForDeploymentPostprocessing = 0; 284 | shellPath = /bin/sh; 285 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 286 | showEnvVarsInLog = 0; 287 | }; 288 | 8B4FA2CA31C25FDD19E9544E /* [CP] Embed Pods Frameworks */ = { 289 | isa = PBXShellScriptBuildPhase; 290 | buildActionMask = 2147483647; 291 | files = ( 292 | ); 293 | inputFileListPaths = ( 294 | ); 295 | inputPaths = ( 296 | "${PODS_ROOT}/Target Support Files/Pods-CollectionPickerView_Example/Pods-CollectionPickerView_Example-frameworks.sh", 297 | "${BUILT_PRODUCTS_DIR}/CollectionPickerView/CollectionPickerView.framework", 298 | ); 299 | name = "[CP] Embed Pods Frameworks"; 300 | outputFileListPaths = ( 301 | ); 302 | outputPaths = ( 303 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/CollectionPickerView.framework", 304 | ); 305 | runOnlyForDeploymentPostprocessing = 0; 306 | shellPath = /bin/sh; 307 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CollectionPickerView_Example/Pods-CollectionPickerView_Example-frameworks.sh\"\n"; 308 | showEnvVarsInLog = 0; 309 | }; 310 | DE7445E27A0075664CBF8962 /* [CP] Check Pods Manifest.lock */ = { 311 | isa = PBXShellScriptBuildPhase; 312 | buildActionMask = 2147483647; 313 | files = ( 314 | ); 315 | inputFileListPaths = ( 316 | ); 317 | inputPaths = ( 318 | "${PODS_PODFILE_DIR_PATH}/Podfile.lock", 319 | "${PODS_ROOT}/Manifest.lock", 320 | ); 321 | name = "[CP] Check Pods Manifest.lock"; 322 | outputFileListPaths = ( 323 | ); 324 | outputPaths = ( 325 | "$(DERIVED_FILE_DIR)/Pods-CollectionPickerView_Tests-checkManifestLockResult.txt", 326 | ); 327 | runOnlyForDeploymentPostprocessing = 0; 328 | shellPath = /bin/sh; 329 | shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n"; 330 | showEnvVarsInLog = 0; 331 | }; 332 | E79105D1937C0EE7E64C605E /* [CP] Embed Pods Frameworks */ = { 333 | isa = PBXShellScriptBuildPhase; 334 | buildActionMask = 2147483647; 335 | files = ( 336 | ); 337 | inputFileListPaths = ( 338 | ); 339 | inputPaths = ( 340 | "${PODS_ROOT}/Target Support Files/Pods-CollectionPickerView_Tests/Pods-CollectionPickerView_Tests-frameworks.sh", 341 | "${BUILT_PRODUCTS_DIR}/Nimble/Nimble.framework", 342 | "${BUILT_PRODUCTS_DIR}/Quick/Quick.framework", 343 | ); 344 | name = "[CP] Embed Pods Frameworks"; 345 | outputFileListPaths = ( 346 | ); 347 | outputPaths = ( 348 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Nimble.framework", 349 | "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Quick.framework", 350 | ); 351 | runOnlyForDeploymentPostprocessing = 0; 352 | shellPath = /bin/sh; 353 | shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-CollectionPickerView_Tests/Pods-CollectionPickerView_Tests-frameworks.sh\"\n"; 354 | showEnvVarsInLog = 0; 355 | }; 356 | /* End PBXShellScriptBuildPhase section */ 357 | 358 | /* Begin PBXSourcesBuildPhase section */ 359 | 607FACCC1AFB9204008FA782 /* Sources */ = { 360 | isa = PBXSourcesBuildPhase; 361 | buildActionMask = 2147483647; 362 | files = ( 363 | C3B186101EE6ACE30004DF38 /* ViewController.swift in Sources */, 364 | 607FACD61AFB9204008FA782 /* AppDelegate.swift in Sources */, 365 | ); 366 | runOnlyForDeploymentPostprocessing = 0; 367 | }; 368 | 607FACE11AFB9204008FA782 /* Sources */ = { 369 | isa = PBXSourcesBuildPhase; 370 | buildActionMask = 2147483647; 371 | files = ( 372 | 607FACEC1AFB9204008FA782 /* Tests.swift in Sources */, 373 | ); 374 | runOnlyForDeploymentPostprocessing = 0; 375 | }; 376 | /* End PBXSourcesBuildPhase section */ 377 | 378 | /* Begin PBXTargetDependency section */ 379 | 607FACE71AFB9204008FA782 /* PBXTargetDependency */ = { 380 | isa = PBXTargetDependency; 381 | target = 607FACCF1AFB9204008FA782 /* CollectionPickerView_Example */; 382 | targetProxy = 607FACE61AFB9204008FA782 /* PBXContainerItemProxy */; 383 | }; 384 | /* End PBXTargetDependency section */ 385 | 386 | /* Begin PBXVariantGroup section */ 387 | 607FACD91AFB9204008FA782 /* Main.storyboard */ = { 388 | isa = PBXVariantGroup; 389 | children = ( 390 | 607FACDA1AFB9204008FA782 /* Base */, 391 | ); 392 | name = Main.storyboard; 393 | sourceTree = ""; 394 | }; 395 | 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */ = { 396 | isa = PBXVariantGroup; 397 | children = ( 398 | 607FACDF1AFB9204008FA782 /* Base */, 399 | ); 400 | name = LaunchScreen.xib; 401 | sourceTree = ""; 402 | }; 403 | /* End PBXVariantGroup section */ 404 | 405 | /* Begin XCBuildConfiguration section */ 406 | 607FACED1AFB9204008FA782 /* Debug */ = { 407 | isa = XCBuildConfiguration; 408 | buildSettings = { 409 | ALWAYS_SEARCH_USER_PATHS = NO; 410 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 411 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 412 | CLANG_CXX_LIBRARY = "libc++"; 413 | CLANG_ENABLE_MODULES = YES; 414 | CLANG_ENABLE_OBJC_ARC = YES; 415 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 416 | CLANG_WARN_BOOL_CONVERSION = YES; 417 | CLANG_WARN_COMMA = YES; 418 | CLANG_WARN_CONSTANT_CONVERSION = YES; 419 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 420 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 421 | CLANG_WARN_EMPTY_BODY = YES; 422 | CLANG_WARN_ENUM_CONVERSION = YES; 423 | CLANG_WARN_INFINITE_RECURSION = YES; 424 | CLANG_WARN_INT_CONVERSION = YES; 425 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 426 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 427 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 428 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 429 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 430 | CLANG_WARN_STRICT_PROTOTYPES = YES; 431 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 432 | CLANG_WARN_UNREACHABLE_CODE = YES; 433 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 434 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 435 | COPY_PHASE_STRIP = NO; 436 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 437 | ENABLE_STRICT_OBJC_MSGSEND = YES; 438 | ENABLE_TESTABILITY = YES; 439 | GCC_C_LANGUAGE_STANDARD = gnu99; 440 | GCC_DYNAMIC_NO_PIC = NO; 441 | GCC_NO_COMMON_BLOCKS = YES; 442 | GCC_OPTIMIZATION_LEVEL = 0; 443 | GCC_PREPROCESSOR_DEFINITIONS = ( 444 | "DEBUG=1", 445 | "$(inherited)", 446 | ); 447 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 448 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 449 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 450 | GCC_WARN_UNDECLARED_SELECTOR = YES; 451 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 452 | GCC_WARN_UNUSED_FUNCTION = YES; 453 | GCC_WARN_UNUSED_VARIABLE = YES; 454 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 455 | MTL_ENABLE_DEBUG_INFO = YES; 456 | ONLY_ACTIVE_ARCH = YES; 457 | SDKROOT = iphoneos; 458 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 459 | }; 460 | name = Debug; 461 | }; 462 | 607FACEE1AFB9204008FA782 /* Release */ = { 463 | isa = XCBuildConfiguration; 464 | buildSettings = { 465 | ALWAYS_SEARCH_USER_PATHS = NO; 466 | CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; 467 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 468 | CLANG_CXX_LIBRARY = "libc++"; 469 | CLANG_ENABLE_MODULES = YES; 470 | CLANG_ENABLE_OBJC_ARC = YES; 471 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 472 | CLANG_WARN_BOOL_CONVERSION = YES; 473 | CLANG_WARN_COMMA = YES; 474 | CLANG_WARN_CONSTANT_CONVERSION = YES; 475 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 476 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 477 | CLANG_WARN_EMPTY_BODY = YES; 478 | CLANG_WARN_ENUM_CONVERSION = YES; 479 | CLANG_WARN_INFINITE_RECURSION = YES; 480 | CLANG_WARN_INT_CONVERSION = YES; 481 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 482 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 483 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 484 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 485 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 486 | CLANG_WARN_STRICT_PROTOTYPES = YES; 487 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 488 | CLANG_WARN_UNREACHABLE_CODE = YES; 489 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 490 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 491 | COPY_PHASE_STRIP = NO; 492 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 493 | ENABLE_NS_ASSERTIONS = NO; 494 | ENABLE_STRICT_OBJC_MSGSEND = YES; 495 | GCC_C_LANGUAGE_STANDARD = gnu99; 496 | GCC_NO_COMMON_BLOCKS = YES; 497 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 498 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 499 | GCC_WARN_UNDECLARED_SELECTOR = YES; 500 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 501 | GCC_WARN_UNUSED_FUNCTION = YES; 502 | GCC_WARN_UNUSED_VARIABLE = YES; 503 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 504 | MTL_ENABLE_DEBUG_INFO = NO; 505 | SDKROOT = iphoneos; 506 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 507 | VALIDATE_PRODUCT = YES; 508 | }; 509 | name = Release; 510 | }; 511 | 607FACF01AFB9204008FA782 /* Debug */ = { 512 | isa = XCBuildConfiguration; 513 | baseConfigurationReference = CF049FDC0AE1FE108336FE52 /* Pods-CollectionPickerView_Example.debug.xcconfig */; 514 | buildSettings = { 515 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 516 | INFOPLIST_FILE = CollectionPickerView/Info.plist; 517 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 518 | MODULE_NAME = ExampleApp; 519 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 520 | PRODUCT_NAME = "$(TARGET_NAME)"; 521 | SWIFT_VERSION = 5.0; 522 | }; 523 | name = Debug; 524 | }; 525 | 607FACF11AFB9204008FA782 /* Release */ = { 526 | isa = XCBuildConfiguration; 527 | baseConfigurationReference = 75517E8F62F0662CADC9172C /* Pods-CollectionPickerView_Example.release.xcconfig */; 528 | buildSettings = { 529 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 530 | INFOPLIST_FILE = CollectionPickerView/Info.plist; 531 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 532 | MODULE_NAME = ExampleApp; 533 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; 534 | PRODUCT_NAME = "$(TARGET_NAME)"; 535 | SWIFT_VERSION = 5.0; 536 | }; 537 | name = Release; 538 | }; 539 | 607FACF31AFB9204008FA782 /* Debug */ = { 540 | isa = XCBuildConfiguration; 541 | baseConfigurationReference = F0757E8364A029EF8A7CE988 /* Pods-CollectionPickerView_Tests.debug.xcconfig */; 542 | buildSettings = { 543 | FRAMEWORK_SEARCH_PATHS = ( 544 | "$(SDKROOT)/Developer/Library/Frameworks", 545 | "$(inherited)", 546 | ); 547 | GCC_PREPROCESSOR_DEFINITIONS = ( 548 | "DEBUG=1", 549 | "$(inherited)", 550 | ); 551 | INFOPLIST_FILE = Tests/Info.plist; 552 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 553 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 554 | PRODUCT_NAME = "$(TARGET_NAME)"; 555 | SWIFT_VERSION = 5.0; 556 | }; 557 | name = Debug; 558 | }; 559 | 607FACF41AFB9204008FA782 /* Release */ = { 560 | isa = XCBuildConfiguration; 561 | baseConfigurationReference = 4FD1FB7AE40A631A08A1205C /* Pods-CollectionPickerView_Tests.release.xcconfig */; 562 | buildSettings = { 563 | FRAMEWORK_SEARCH_PATHS = ( 564 | "$(SDKROOT)/Developer/Library/Frameworks", 565 | "$(inherited)", 566 | ); 567 | INFOPLIST_FILE = Tests/Info.plist; 568 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 569 | PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; 570 | PRODUCT_NAME = "$(TARGET_NAME)"; 571 | SWIFT_VERSION = 5.0; 572 | }; 573 | name = Release; 574 | }; 575 | /* End XCBuildConfiguration section */ 576 | 577 | /* Begin XCConfigurationList section */ 578 | 607FACCB1AFB9204008FA782 /* Build configuration list for PBXProject "CollectionPickerView" */ = { 579 | isa = XCConfigurationList; 580 | buildConfigurations = ( 581 | 607FACED1AFB9204008FA782 /* Debug */, 582 | 607FACEE1AFB9204008FA782 /* Release */, 583 | ); 584 | defaultConfigurationIsVisible = 0; 585 | defaultConfigurationName = Release; 586 | }; 587 | 607FACEF1AFB9204008FA782 /* Build configuration list for PBXNativeTarget "CollectionPickerView_Example" */ = { 588 | isa = XCConfigurationList; 589 | buildConfigurations = ( 590 | 607FACF01AFB9204008FA782 /* Debug */, 591 | 607FACF11AFB9204008FA782 /* Release */, 592 | ); 593 | defaultConfigurationIsVisible = 0; 594 | defaultConfigurationName = Release; 595 | }; 596 | 607FACF21AFB9204008FA782 /* Build configuration list for PBXNativeTarget "CollectionPickerView_Tests" */ = { 597 | isa = XCConfigurationList; 598 | buildConfigurations = ( 599 | 607FACF31AFB9204008FA782 /* Debug */, 600 | 607FACF41AFB9204008FA782 /* Release */, 601 | ); 602 | defaultConfigurationIsVisible = 0; 603 | defaultConfigurationName = Release; 604 | }; 605 | /* End XCConfigurationList section */ 606 | }; 607 | rootObject = 607FACC81AFB9204008FA782 /* Project object */; 608 | } 609 | --------------------------------------------------------------------------------