├── .gitignore ├── LICENSE ├── Package.swift ├── Previews ├── animation.gif ├── direction.gif ├── rewind.gif ├── swipe.gif └── undo.gif ├── README.md ├── ZLSwipeableViewSwift.podspec ├── ZLSwipeableViewSwift ├── Direction.swift ├── Info.plist ├── Scheduler.swift ├── ViewManager.swift ├── ZLSwipeableView.swift └── ZLSwipeableViewSwift.xcodeproj │ ├── project.pbxproj │ ├── project.xcworkspace │ └── contents.xcworkspacedata │ └── xcshareddata │ └── xcschemes │ └── ZLSwipeableViewSwift.xcscheme └── ZLSwipeableViewSwiftDemo ├── Podfile ├── Podfile.lock ├── Pods ├── Cartography │ ├── Cartography │ │ ├── Align.swift │ │ ├── Coefficients.swift │ │ ├── Compound.swift │ │ ├── Constrain.swift │ │ ├── Constraint.swift │ │ ├── ConstraintGroup.swift │ │ ├── Context.swift │ │ ├── Dimension.swift │ │ ├── Distribute.swift │ │ ├── Edge.swift │ │ ├── Edges.swift │ │ ├── Expression.swift │ │ ├── Extensions.swift │ │ ├── LayoutProxy.swift │ │ ├── LayoutSupport.swift │ │ ├── Point.swift │ │ ├── Priority.swift │ │ ├── Property.swift │ │ ├── Size.swift │ │ ├── View.swift │ │ └── ViewUtils.swift │ ├── LICENSE │ └── README.md ├── Manifest.lock ├── Pods.xcodeproj │ └── project.pbxproj ├── Target Support Files │ ├── Cartography │ │ ├── Cartography-dummy.m │ │ ├── Cartography-prefix.pch │ │ ├── Cartography-umbrella.h │ │ ├── Cartography.modulemap │ │ ├── Cartography.xcconfig │ │ └── Info.plist │ ├── Pods-ZLSwipeableViewSwiftDemo │ │ ├── Info.plist │ │ ├── Pods-ZLSwipeableViewSwiftDemo-acknowledgements.markdown │ │ ├── Pods-ZLSwipeableViewSwiftDemo-acknowledgements.plist │ │ ├── Pods-ZLSwipeableViewSwiftDemo-dummy.m │ │ ├── Pods-ZLSwipeableViewSwiftDemo-frameworks.sh │ │ ├── Pods-ZLSwipeableViewSwiftDemo-resources.sh │ │ ├── Pods-ZLSwipeableViewSwiftDemo-umbrella.h │ │ ├── Pods-ZLSwipeableViewSwiftDemo.debug.xcconfig │ │ ├── Pods-ZLSwipeableViewSwiftDemo.modulemap │ │ └── Pods-ZLSwipeableViewSwiftDemo.release.xcconfig │ ├── Pods-ZLSwipeableViewSwiftDemoTests │ │ ├── Info.plist │ │ ├── Pods-ZLSwipeableViewSwiftDemoTests-acknowledgements.markdown │ │ ├── Pods-ZLSwipeableViewSwiftDemoTests-acknowledgements.plist │ │ ├── Pods-ZLSwipeableViewSwiftDemoTests-dummy.m │ │ ├── Pods-ZLSwipeableViewSwiftDemoTests-frameworks.sh │ │ ├── Pods-ZLSwipeableViewSwiftDemoTests-resources.sh │ │ ├── Pods-ZLSwipeableViewSwiftDemoTests-umbrella.h │ │ ├── Pods-ZLSwipeableViewSwiftDemoTests.debug.xcconfig │ │ ├── Pods-ZLSwipeableViewSwiftDemoTests.modulemap │ │ └── Pods-ZLSwipeableViewSwiftDemoTests.release.xcconfig │ └── UIColor+FlatColors │ │ ├── Info.plist │ │ ├── UIColor+FlatColors-dummy.m │ │ ├── UIColor+FlatColors-prefix.pch │ │ ├── UIColor+FlatColors-umbrella.h │ │ ├── UIColor+FlatColors.modulemap │ │ └── UIColor+FlatColors.xcconfig └── UIColor+FlatColors │ ├── LICENSE │ ├── README.md │ └── UIColor+FlatColors │ ├── UIColor+FlatColors.h │ └── UIColor+FlatColors.m ├── ZLSwipeableViewSwiftDemo.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── ZLSwipeableViewSwiftDemo.xcworkspace └── contents.xcworkspacedata ├── ZLSwipeableViewSwiftDemo ├── AlwaysSwipeDemoViewController.swift ├── AppDelegate.swift ├── Base.lproj │ └── LaunchScreen.xib ├── CardContentView.xib ├── CardView.swift ├── CustomAnimationDemoViewController.swift ├── CustomDirectionDemoViewController.swift ├── CustomSwipeDemoViewController.swift ├── HistoryDemoViewController.swift ├── Images.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json ├── Info.plist ├── MenuTableViewController.swift ├── PreviousViewDemoViewController.swift ├── ShouldSwipeDemoViewController.swift └── ZLSwipeableViewController.swift └── ZLSwipeableViewSwiftDemoTests ├── DirectionTests.swift ├── Info.plist ├── ViewManagerTests.swift └── ZLSwipeableViewSwiftDemoTests.swift /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | .DS_Store 20 | .swiftpm 21 | 22 | # CocoaPods 23 | # 24 | # We recommend against adding the Pods directory to your .gitignore. However 25 | # you should judge for yourself, the pros and cons are mentioned at: 26 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 27 | # 28 | # Pods/ 29 | 30 | # Carthage 31 | # 32 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 33 | # Carthage/Checkouts 34 | 35 | Carthage/Build 36 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 Zhixuan Lai 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /Package.swift: -------------------------------------------------------------------------------- 1 | // swift-tools-version:5.5 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: "ZLSwipeableViewSwift", 8 | platforms: [.iOS(.v13)], 9 | products: [ 10 | .library( 11 | name: "ZLSwipeableViewSwift", 12 | targets: ["ZLSwipeableViewSwift"]), 13 | ], 14 | dependencies: [], 15 | targets: [ 16 | .target( 17 | name: "ZLSwipeableViewSwift", 18 | dependencies: [], 19 | path: "ZLSwipeableViewSwift", 20 | exclude: ["Info.plist"] 21 | ), 22 | ] 23 | ) 24 | -------------------------------------------------------------------------------- /Previews/animation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhxnlai/ZLSwipeableViewSwift/4e694c883dec91f858eb5a2af5fd9ada3d2e47dc/Previews/animation.gif -------------------------------------------------------------------------------- /Previews/direction.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhxnlai/ZLSwipeableViewSwift/4e694c883dec91f858eb5a2af5fd9ada3d2e47dc/Previews/direction.gif -------------------------------------------------------------------------------- /Previews/rewind.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhxnlai/ZLSwipeableViewSwift/4e694c883dec91f858eb5a2af5fd9ada3d2e47dc/Previews/rewind.gif -------------------------------------------------------------------------------- /Previews/swipe.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhxnlai/ZLSwipeableViewSwift/4e694c883dec91f858eb5a2af5fd9ada3d2e47dc/Previews/swipe.gif -------------------------------------------------------------------------------- /Previews/undo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zhxnlai/ZLSwipeableViewSwift/4e694c883dec91f858eb5a2af5fd9ada3d2e47dc/Previews/undo.gif -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ZLSwipeableViewSwift 2 | A simple view for building card like interface like [Tinder](http://www.gotinder.com/) and [Potluck](https://www.potluck.it/). ZLSwipeableViewSwift is based on [ZLSwipeableView](https://github.com/zhxnlai/ZLSwipeableView/). 3 | 4 | Preview 5 | --- 6 | ### Custom Animation 7 | ![direction](Previews/animation.gif) 8 | ### Custom Swipe 9 | ![direction](Previews/swipe.gif) 10 | ### Custom Direction 11 | ![direction](Previews/direction.gif) 12 | ### Undo 13 | ![direction](Previews/undo.gif) 14 | ### Rewind 15 | ![direction](Previews/rewind.gif) 16 | 17 | CocoaPods 18 | --- 19 | You can install `ZLSwipeableViewSwift` through CocoaPods adding the following to your Podfile: 20 | 21 | pod 'ZLSwipeableViewSwift' 22 | use_frameworks! 23 | Then import it using: 24 | 25 | import ZLSwipeableViewSwift 26 | 27 | Carthage 28 | --- 29 | You can install `ZLSwipeableViewSwift` through Carthage by adding `github "zhxnlai/ZLSwipeableViewSwift"` to your Cartfile 30 | 31 | Swift Package Manager 32 | --- 33 | You can install `ZLSwipeableViewSwift` through Swift Package Manager by adding it to the `dependencies` value of your `Package.swift`. 34 | 35 | ```swift 36 | dependencies: [ 37 | .package(url: "https://github.com/zhxnlai/ZLSwipeableViewSwift", .branchItem("master")) 38 | ] 39 | ``` 40 | 41 | Usage 42 | --- 43 | Check out the [demo app](https://github.com/zhxnlai/ZLSwipeableViewSwift/archive/master.zip) for an example. It contains the following demos: Default, Custom Animation, Custom Swipe, Allowed Direction, History, Previous View, Should Swipe and Always Swipe. 44 | 45 | ### Instantiation 46 | `ZLSwipeableView` can be added to storyboard or instantiated programmatically: 47 | ~~~swift 48 | var swipeableView = ZLSwipeableView(frame: CGRect(x: 0, y: 0, width: 300, height: 500)) 49 | view.addSubview(swipeableView) 50 | ~~~ 51 | 52 | ### Adding Views 53 | `ZLSwipeableView` supports both adding views to the front and to the back. 54 | ~~~swift 55 | public var numberOfActiveView = UInt(4) 56 | public var nextView: (() -> UIView?)? 57 | public var previousView: (() -> UIView?)? 58 | ~~~ 59 | #### Adding views to the back 60 | `nextView`, a closure that returns an `UIView`, works with `loadViews` and `numberOfActiveView`. It acts as the data source. After defining it, `ZLSwipeableView` will call `loadViews` which will invoke `nextView` `numberOfActiveView` times and insert them in the back. `loadViews` will also be called each time a view is swiped. 61 | 62 | ~~~swift 63 | public func loadViews() 64 | // Usage: 65 | swipeableView.numberOfActiveView = 3 66 | swipeableView.nextView = { 67 | return UIView() 68 | } 69 | swipeableView.loadViews() // optional, automatically call after nextView is set 70 | ~~~ 71 | 72 | #### Adding views to the front 73 | `previousView` works with `rewind`, which inserts a view in the front and positions it at the center with animation. 74 | Note that `rewind` calls `previousView` only when `history` is empty, otherwise it returns the most recently swiped view. Please try out the [Previous View](#rewind) example for more information. 75 | ~~~swift 76 | public func rewind() 77 | // Usage: 78 | swipeableView.previousView = { 79 | return UIView() 80 | } 81 | swipeableView.rewind() 82 | ~~~ 83 | 84 | #### Interface Builder 85 | If you need to work with Interface Builder, the demo app includes examples of both creating views programmatically and loading views from Xib files that [use Auto Layout](https://github.com/zhxnlai/ZLSwipeableView/issues/9). 86 | 87 | ### Removing Views 88 | 89 | #### Swiping programmatically 90 | The user can swipe views in the allowed directions. This can also happen programmatically. 91 | 92 | You can swipe the top view programmatically in one of the predefined directions or with point and direction in the view's coordinate. 93 | ~~~swift 94 | public func swipeTopView(inDirection direction: Direction) 95 | // Usage: 96 | swipeableView.swipeTopView(inDirection: .Left) 97 | swipeableView.swipeTopView(inDirection: .Up) 98 | swipeableView.swipeTopView(inDirection: .Right) 99 | swipeableView.swipeTopView(inDirection: .Down) 100 | 101 | public func swipeTopView(fromPoint location: CGPoint, inDirection directionVector: CGVector) 102 | // Usage: 103 | swipeableView.swipeTopView(fromPoint: CGPoint(x: 100, y: 30), inDirection: CGVector(dx: 100, dy: -800)) 104 | ~~~ 105 | 106 | #### Rewinding 107 | `ZLSwipeableView` keeps a history of swiped views. They can be retrieved by calling `rewind`. 108 | ~~~swift 109 | public var history = [UIView]() 110 | public var numberOfHistoryItem = UInt(10) 111 | 112 | public func rewind() 113 | ~~~ 114 | 115 | #### Removing all views 116 | To discard all views and reload programmatically (discarded views cannot by rewinded): 117 | ~~~swift 118 | swipeableView.discardViews() 119 | swipeableView.loadViews() 120 | ~~~ 121 | 122 | ### Delegate 123 | Here is a list of callbacks you can listen to: 124 | ~~~swift 125 | swipeableView.didStart = {view, location in 126 | print("Did start swiping view at location: \(location)") 127 | } 128 | swipeableView.swiping = {view, location, translation in 129 | print("Swiping at view location: \(location) translation: \(translation)") 130 | } 131 | swipeableView.didEnd = {view, location in 132 | print("Did end swiping view at location: \(location)") 133 | } 134 | swipeableView.didSwipe = {view, direction, vector in 135 | print("Did swipe view in direction: \(direction), vector: \(vector)") 136 | } 137 | swipeableView.didCancel = {view in 138 | print("Did cancel swiping view") 139 | } 140 | ~~~ 141 | 142 | 143 | ### Customization 144 | Here is a list of customizable behaviors: 145 | ~~~swift 146 | public var animateView = ZLSwipeableView.defaultAnimateViewHandler() 147 | public var interpretDirection = ZLSwipeableView.defaultInterpretDirectionHandler() 148 | public var shouldSwipeView = ZLSwipeableView.defaultShouldSwipeViewHandler() 149 | public var angle = CGFloat(1.0) 150 | public var minTranslationInPercent = CGFloat(0.25) 151 | public var minVelocityInPointPerSecond = CGFloat(750) 152 | public var allowedDirection = Direction.Horizontal 153 | ~~~ 154 | 155 | #### interpretDirection 156 | You can change how the direction gets interpreted by overriding the `interpretDirection` property. Take a look at the [Custom Swipe](#custom-swipe) example for details. 157 | 158 | #### animateView 159 | You can create custom animation by overriding the `animateView` property. Take a look at the [Custom Animation](#custom-animation) example for details. 160 | 161 | #### Should Swipe 162 | `shouldSwipeView`, `minTranslationInPercent` and `minVelocityInPointPerSecond` determines whether a view should be swiped or not. Please see the Should Swipe example for details. 163 | 164 | #### allowedDirection 165 | The `allowedDirection` property limits the directions in which the user is allowed to swipe. Please see the [Custom Direction](#custom-direction) example for details. 166 | ~~~swift 167 | swipeableView.allowedDirection = .Left | .Up 168 | swipeableView.allowedDirection = .All 169 | ~~~ 170 | 171 | ### angle 172 | 173 | You can change the rotation of the swipe views with the 'angle' property 174 | 175 | ### Misc 176 | 177 | ~~~swift 178 | public func topView() -> UIView? 179 | 180 | public func activeViews() -> [UIView] 181 | ~~~ 182 | 183 | Requirements 184 | --- 185 | - iOS 7 or higher. 186 | 187 | Credits 188 | --- 189 | Big thanks to the [contributors](https://github.com/zhxnlai/ZLSwipeableView/graphs/contributors) of ZLSwipeableView. 190 | 191 | License 192 | --- 193 | ZLSwipeableViewSwift is available under MIT license. See the LICENSE file for more info. 194 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwift.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "ZLSwipeableViewSwift" 3 | s.version = "0.0.9" 4 | s.summary = "A simple view for building card like interface like Tinder and Potluck." 5 | s.description = <<-DESC 6 | ZLSwipeableViewSwift is a simple view for building card like interface like Tinder and Potluck. 7 | DESC 8 | s.homepage = "https://github.com/zhxnlai/ZLSwipeableViewSwift" 9 | s.screenshots = "https://github.com/zhxnlai/ZLSwipeableViewSwift/raw/master/Previews/animation.gif", "https://github.com/zhxnlai/ZLSwipeableViewSwift/raw/master/Previews/swipe.gif", "https://github.com/zhxnlai/ZLSwipeableViewSwift/raw/master/Previews/direction.gif", "https://github.com/zhxnlai/ZLSwipeableViewSwift/raw/master/Previews/undo.gif" 10 | s.license = { :type => "MIT", :file => "LICENSE" } 11 | s.author = { "Zhixuan Lai" => "zhxnlai@gmail.com" } 12 | s.social_media_url = "http://twitter.com/ZhixuanLai" 13 | 14 | s.platform = :ios, "8.0" 15 | 16 | s.source = { :git => "https://github.com/zhxnlai/ZLSwipeableViewSwift.git", :tag => "0.0.9" } 17 | s.source_files = "ZLSwipeableViewSwift/*.swift" 18 | 19 | s.framework = "UIKit" 20 | 21 | s.requires_arc = true 22 | end 23 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwift/Direction.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Direction.swift 3 | // ZLSwipeableViewSwift 4 | // 5 | // Created by Andrew Breckenridge on 5/17/16. 6 | // Copyright © 2016 Andrew Breckenridge. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public typealias ZLSwipeableViewDirection = Direction 12 | 13 | extension Direction: Equatable {} 14 | public func ==(lhs: Direction, rhs: Direction) -> Bool { 15 | return lhs.rawValue == rhs.rawValue 16 | } 17 | 18 | /** 19 | * Swiped direction. 20 | */ 21 | public struct Direction : OptionSet, CustomStringConvertible { 22 | 23 | public var rawValue: UInt 24 | 25 | public init(rawValue: UInt) { 26 | self.rawValue = rawValue 27 | } 28 | 29 | public static let None = Direction(rawValue: 0b0000) 30 | public static let Left = Direction(rawValue: 0b0001) 31 | public static let Right = Direction(rawValue: 0b0010) 32 | public static let Up = Direction(rawValue: 0b0100) 33 | public static let Down = Direction(rawValue: 0b1000) 34 | public static let Horizontal: Direction = [Left, Right] 35 | public static let Vertical: Direction = [Up, Down] 36 | public static let All: Direction = [Horizontal, Vertical] 37 | 38 | public static func fromPoint(_ point: CGPoint) -> Direction { 39 | switch (point.x, point.y) { 40 | case let (x, y) where abs(x) >= abs(y) && x > 0: 41 | return .Right 42 | case let (x, y) where abs(x) >= abs(y) && x < 0: 43 | return .Left 44 | case let (x, y) where abs(x) < abs(y) && y < 0: 45 | return .Up 46 | case let (x, y) where abs(x) < abs(y) && y > 0: 47 | return .Down 48 | case (_, _): 49 | return .None 50 | } 51 | } 52 | 53 | public var description: String { 54 | switch self { 55 | case Direction.None: 56 | return "None" 57 | case Direction.Left: 58 | return "Left" 59 | case Direction.Right: 60 | return "Right" 61 | case Direction.Up: 62 | return "Up" 63 | case Direction.Down: 64 | return "Down" 65 | case Direction.Horizontal: 66 | return "Horizontal" 67 | case Direction.Vertical: 68 | return "Vertical" 69 | case Direction.All: 70 | return "All" 71 | default: 72 | return "Unknown" 73 | } 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwift/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwift/Scheduler.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Scheduler.swift 3 | // ZLSwipeableViewSwift 4 | // 5 | // Created by Andrew Breckenridge on 5/17/16. 6 | // Copyright © 2016 Andrew Breckenridge. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class Scheduler : NSObject { 12 | 13 | typealias Action = () -> Void 14 | typealias EndCondition = () -> Bool 15 | 16 | var timer: Timer? 17 | var action: Action? 18 | var endCondition: EndCondition? 19 | 20 | func scheduleRepeatedly(_ action: @escaping Action, interval: TimeInterval, endCondition: @escaping EndCondition) { 21 | guard timer == nil && interval > 0 else { return } 22 | self.action = action 23 | self.endCondition = endCondition 24 | timer = Timer.scheduledTimer(timeInterval: interval, target: self, selector: #selector(Scheduler.doAction(_:)), userInfo: nil, repeats: true) 25 | } 26 | 27 | @objc func doAction(_ timer: Timer) { 28 | guard let action = action, let endCondition = endCondition, !endCondition() else { 29 | timer.invalidate() 30 | self.timer = nil 31 | self.action = nil 32 | self.endCondition = nil 33 | return 34 | } 35 | action() 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwift/ViewManager.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewManager.swift 3 | // ZLSwipeableViewSwift 4 | // 5 | // Created by Andrew Breckenridge on 5/17/16. 6 | // Copyright © 2016 Andrew Breckenridge. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ViewManager : NSObject { 12 | 13 | // Snapping -> [Moving]+ -> Snapping 14 | // Snapping -> [Moving]+ -> Swiping -> Snapping 15 | enum State { 16 | case snapping(CGPoint), moving(CGPoint), swiping(CGPoint, CGVector) 17 | } 18 | 19 | var state: State { 20 | didSet { 21 | if case .snapping(_) = oldValue, case let .moving(point) = state { 22 | unsnapView() 23 | attachView(toPoint: point) 24 | } else if case .snapping(_) = oldValue, case let .swiping(origin, direction) = state { 25 | unsnapView() 26 | attachView(toPoint: origin) 27 | pushView(fromPoint: origin, inDirection: direction) 28 | } else if case .moving(_) = oldValue, case let .moving(point) = state { 29 | moveView(toPoint: point) 30 | } else if case .moving(_) = oldValue, case let .snapping(point) = state { 31 | detachView() 32 | snapView(point) 33 | } else if case .moving(_) = oldValue, case let .swiping(origin, direction) = state { 34 | pushView(fromPoint: origin, inDirection: direction) 35 | } else if case .swiping(_, _) = oldValue, case let .snapping(point) = state { 36 | unpushView() 37 | detachView() 38 | snapView(point) 39 | } 40 | } 41 | } 42 | 43 | /// To be added to view and removed 44 | fileprivate class ZLPanGestureRecognizer: UIPanGestureRecognizer { } 45 | fileprivate class ZLTapGestureRecognizer: UITapGestureRecognizer { } 46 | 47 | static fileprivate let anchorViewWidth = CGFloat(1000) 48 | fileprivate var anchorView = UIView(frame: CGRect(x: 0, y: 0, width: anchorViewWidth, height: anchorViewWidth)) 49 | 50 | fileprivate var snapBehavior: UISnapBehavior! 51 | fileprivate var viewToAnchorViewAttachmentBehavior: UIAttachmentBehavior! 52 | fileprivate var anchorViewToPointAttachmentBehavior: UIAttachmentBehavior! 53 | fileprivate var pushBehavior: UIPushBehavior! 54 | 55 | fileprivate let view: UIView 56 | fileprivate let containerView: UIView 57 | fileprivate let miscContainerView: UIView 58 | fileprivate let animator: UIDynamicAnimator 59 | fileprivate weak var swipeableView: ZLSwipeableView? 60 | 61 | init(view: UIView, containerView: UIView, index: Int, miscContainerView: UIView, animator: UIDynamicAnimator, swipeableView: ZLSwipeableView) { 62 | self.view = view 63 | self.containerView = containerView 64 | self.miscContainerView = miscContainerView 65 | self.animator = animator 66 | self.swipeableView = swipeableView 67 | self.state = ViewManager.defaultSnappingState(view) 68 | 69 | super.init() 70 | 71 | view.addGestureRecognizer(ZLPanGestureRecognizer(target: self, action: #selector(ViewManager.handlePan(_:)))) 72 | if swipeableView.didTap != nil { 73 | self.addTapRecognizer() 74 | } 75 | miscContainerView.addSubview(anchorView) 76 | containerView.insertSubview(view, at: index) 77 | } 78 | 79 | static func defaultSnappingState(_ view: UIView) -> State { 80 | return .snapping(view.convert(view.center, from: view.superview)) 81 | } 82 | 83 | func snappingStateAtContainerCenter() -> State { 84 | guard let swipeableView = swipeableView else { return ViewManager.defaultSnappingState(view) } 85 | return .snapping(containerView.convert(swipeableView.center, from: swipeableView.superview)) 86 | } 87 | 88 | deinit { 89 | if let snapBehavior = snapBehavior { 90 | removeBehavior(snapBehavior) 91 | } 92 | if let viewToAnchorViewAttachmentBehavior = viewToAnchorViewAttachmentBehavior { 93 | removeBehavior(viewToAnchorViewAttachmentBehavior) 94 | } 95 | if let anchorViewToPointAttachmentBehavior = anchorViewToPointAttachmentBehavior { 96 | removeBehavior(anchorViewToPointAttachmentBehavior) 97 | } 98 | if let pushBehavior = pushBehavior { 99 | removeBehavior(pushBehavior) 100 | } 101 | 102 | for gestureRecognizer in view.gestureRecognizers! { 103 | if gestureRecognizer.isKind(of: ZLPanGestureRecognizer.classForCoder()) { 104 | view.removeGestureRecognizer(gestureRecognizer) 105 | } 106 | } 107 | 108 | anchorView.removeFromSuperview() 109 | view.removeFromSuperview() 110 | } 111 | 112 | @objc func handlePan(_ recognizer: UIPanGestureRecognizer) { 113 | guard let swipeableView = swipeableView else { return } 114 | 115 | let translation = recognizer.translation(in: containerView) 116 | let location = recognizer.location(in: containerView) 117 | let velocity = recognizer.velocity(in: containerView) 118 | let movement = Movement(location: location, translation: translation, velocity: velocity) 119 | 120 | switch recognizer.state { 121 | case .began: 122 | guard case .snapping(_) = state else { return } 123 | state = .moving(location) 124 | swipeableView.didStart?(view, location) 125 | case .changed: 126 | guard case .moving(_) = state else { return } 127 | state = .moving(location) 128 | swipeableView.swiping?(view, location, translation) 129 | case .ended, .cancelled: 130 | guard case .moving(_) = state else { return } 131 | if swipeableView.shouldSwipeView(view, movement, swipeableView) { 132 | let directionVector = CGVector(point: translation.normalized * max(velocity.magnitude, swipeableView.minVelocityInPointPerSecond)) 133 | state = .swiping(location, directionVector) 134 | swipeableView.swipeView(view, location: location, directionVector: directionVector) 135 | } else { 136 | state = snappingStateAtContainerCenter() 137 | swipeableView.didCancel?(view) 138 | } 139 | swipeableView.didEnd?(view, location) 140 | default: 141 | break 142 | } 143 | } 144 | 145 | func addTapRecognizer() { 146 | for gesture in view.gestureRecognizers ?? [] { 147 | if let tapGesture = gesture as? ZLTapGestureRecognizer { 148 | 149 | // Remove previous tap gesture 150 | view.removeGestureRecognizer(tapGesture) 151 | 152 | } 153 | } 154 | 155 | view.addGestureRecognizer(ZLTapGestureRecognizer(target: self, action: #selector(ViewManager.handleTap(_:)))) 156 | } 157 | 158 | @objc func handleTap(_ recognizer: UITapGestureRecognizer) { 159 | guard let swipeableView = swipeableView, let topView = swipeableView.topView() else { return } 160 | 161 | let location = recognizer.location(in: containerView) 162 | swipeableView.didTap?(topView, location) 163 | } 164 | 165 | fileprivate func snapView(_ point: CGPoint) { 166 | snapBehavior = UISnapBehavior(item: view, snapTo: point) 167 | snapBehavior!.damping = 0.75 168 | addBehavior(snapBehavior) 169 | } 170 | 171 | fileprivate func unsnapView() { 172 | guard let snapBehavior = snapBehavior else { return } 173 | removeBehavior(snapBehavior) 174 | } 175 | 176 | func resnapView() { 177 | if case .snapping(_) = state { 178 | unsnapView() 179 | state = snappingStateAtContainerCenter() 180 | } 181 | } 182 | 183 | fileprivate func attachView(toPoint point: CGPoint) { 184 | anchorView.center = point 185 | anchorView.backgroundColor = UIColor.blue 186 | anchorView.isHidden = true 187 | 188 | // attach aView to anchorView 189 | let p = view.center 190 | viewToAnchorViewAttachmentBehavior = UIAttachmentBehavior(item: view, offsetFromCenter: UIOffset(horizontal: -(p.x - point.x), vertical: -(p.y - point.y)), attachedTo: anchorView, offsetFromCenter: UIOffset.zero) 191 | viewToAnchorViewAttachmentBehavior!.length = 0 192 | 193 | // attach anchorView to point 194 | anchorViewToPointAttachmentBehavior = UIAttachmentBehavior(item: anchorView, offsetFromCenter: UIOffset.zero, attachedToAnchor: point) 195 | anchorViewToPointAttachmentBehavior!.damping = 100 196 | anchorViewToPointAttachmentBehavior!.length = 0 197 | 198 | addBehavior(viewToAnchorViewAttachmentBehavior!) 199 | addBehavior(anchorViewToPointAttachmentBehavior!) 200 | } 201 | 202 | fileprivate func moveView(toPoint point: CGPoint) { 203 | guard let _ = viewToAnchorViewAttachmentBehavior, let toPoint = anchorViewToPointAttachmentBehavior else { return } 204 | toPoint.anchorPoint = point 205 | } 206 | 207 | fileprivate func detachView() { 208 | guard let viewToAnchorViewAttachmentBehavior = viewToAnchorViewAttachmentBehavior, let anchorViewToPointAttachmentBehavior = anchorViewToPointAttachmentBehavior else { return } 209 | removeBehavior(viewToAnchorViewAttachmentBehavior) 210 | removeBehavior(anchorViewToPointAttachmentBehavior) 211 | } 212 | 213 | fileprivate func pushView(fromPoint point: CGPoint, inDirection direction: CGVector) { 214 | guard let _ = viewToAnchorViewAttachmentBehavior, let anchorViewToPointAttachmentBehavior = anchorViewToPointAttachmentBehavior else { return } 215 | 216 | removeBehavior(anchorViewToPointAttachmentBehavior) 217 | 218 | pushBehavior = UIPushBehavior(items: [anchorView], mode: .instantaneous) 219 | pushBehavior.pushDirection = direction 220 | addBehavior(pushBehavior) 221 | } 222 | 223 | fileprivate func unpushView() { 224 | guard let pushBehavior = pushBehavior else { return } 225 | removeBehavior(pushBehavior) 226 | } 227 | 228 | fileprivate func addBehavior(_ behavior: UIDynamicBehavior) { 229 | animator.addBehavior(behavior) 230 | } 231 | 232 | fileprivate func removeBehavior(_ behavior: UIDynamicBehavior) { 233 | animator.removeBehavior(behavior) 234 | } 235 | 236 | } 237 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwift/ZLSwipeableViewSwift.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 466AFFEC1CEB8BA1006FF62A /* Direction.swift in Sources */ = {isa = PBXBuildFile; fileRef = 466AFFEB1CEB8BA1006FF62A /* Direction.swift */; }; 11 | 466AFFEE1CEB8CD6006FF62A /* ViewManager.swift in Sources */ = {isa = PBXBuildFile; fileRef = 466AFFED1CEB8CD6006FF62A /* ViewManager.swift */; }; 12 | 466AFFF01CEB8CEB006FF62A /* Scheduler.swift in Sources */ = {isa = PBXBuildFile; fileRef = 466AFFEF1CEB8CEB006FF62A /* Scheduler.swift */; }; 13 | 46C0F0351C68AC90004BE1B3 /* ZLSwipeableView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 46C0F0341C68AC90004BE1B3 /* ZLSwipeableView.swift */; }; 14 | /* End PBXBuildFile section */ 15 | 16 | /* Begin PBXFileReference section */ 17 | 460B72511B76D3E600BB5ED8 /* ZLSwipeableViewSwift.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = ZLSwipeableViewSwift.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 18 | 466AFFEB1CEB8BA1006FF62A /* Direction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Direction.swift; sourceTree = SOURCE_ROOT; }; 19 | 466AFFED1CEB8CD6006FF62A /* ViewManager.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewManager.swift; sourceTree = SOURCE_ROOT; }; 20 | 466AFFEF1CEB8CEB006FF62A /* Scheduler.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Scheduler.swift; sourceTree = SOURCE_ROOT; }; 21 | 46C0F0341C68AC90004BE1B3 /* ZLSwipeableView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZLSwipeableView.swift; sourceTree = SOURCE_ROOT; }; 22 | 46C0F0361C68ACA1004BE1B3 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = SOURCE_ROOT; }; 23 | /* End PBXFileReference section */ 24 | 25 | /* Begin PBXFrameworksBuildPhase section */ 26 | 460B724D1B76D3E600BB5ED8 /* Frameworks */ = { 27 | isa = PBXFrameworksBuildPhase; 28 | buildActionMask = 2147483647; 29 | files = ( 30 | ); 31 | runOnlyForDeploymentPostprocessing = 0; 32 | }; 33 | /* End PBXFrameworksBuildPhase section */ 34 | 35 | /* Begin PBXGroup section */ 36 | 460B72471B76D3E600BB5ED8 = { 37 | isa = PBXGroup; 38 | children = ( 39 | 460B72531B76D3E600BB5ED8 /* ZLSwipeableViewSwift */, 40 | 460B72521B76D3E600BB5ED8 /* Products */, 41 | ); 42 | sourceTree = ""; 43 | }; 44 | 460B72521B76D3E600BB5ED8 /* Products */ = { 45 | isa = PBXGroup; 46 | children = ( 47 | 460B72511B76D3E600BB5ED8 /* ZLSwipeableViewSwift.framework */, 48 | ); 49 | name = Products; 50 | sourceTree = ""; 51 | }; 52 | 460B72531B76D3E600BB5ED8 /* ZLSwipeableViewSwift */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | 46C0F0341C68AC90004BE1B3 /* ZLSwipeableView.swift */, 56 | 466AFFEB1CEB8BA1006FF62A /* Direction.swift */, 57 | 466AFFED1CEB8CD6006FF62A /* ViewManager.swift */, 58 | 466AFFEF1CEB8CEB006FF62A /* Scheduler.swift */, 59 | 46C0F0361C68ACA1004BE1B3 /* Info.plist */, 60 | ); 61 | path = ZLSwipeableViewSwift; 62 | sourceTree = ""; 63 | }; 64 | /* End PBXGroup section */ 65 | 66 | /* Begin PBXHeadersBuildPhase section */ 67 | 460B724E1B76D3E600BB5ED8 /* Headers */ = { 68 | isa = PBXHeadersBuildPhase; 69 | buildActionMask = 2147483647; 70 | files = ( 71 | ); 72 | runOnlyForDeploymentPostprocessing = 0; 73 | }; 74 | /* End PBXHeadersBuildPhase section */ 75 | 76 | /* Begin PBXNativeTarget section */ 77 | 460B72501B76D3E600BB5ED8 /* ZLSwipeableViewSwift */ = { 78 | isa = PBXNativeTarget; 79 | buildConfigurationList = 460B72591B76D3E600BB5ED8 /* Build configuration list for PBXNativeTarget "ZLSwipeableViewSwift" */; 80 | buildPhases = ( 81 | 460B724C1B76D3E600BB5ED8 /* Sources */, 82 | 460B724D1B76D3E600BB5ED8 /* Frameworks */, 83 | 460B724E1B76D3E600BB5ED8 /* Headers */, 84 | 460B724F1B76D3E600BB5ED8 /* Resources */, 85 | ); 86 | buildRules = ( 87 | ); 88 | dependencies = ( 89 | ); 90 | name = ZLSwipeableViewSwift; 91 | productName = ZLSwipeableViewSwift; 92 | productReference = 460B72511B76D3E600BB5ED8 /* ZLSwipeableViewSwift.framework */; 93 | productType = "com.apple.product-type.framework"; 94 | }; 95 | /* End PBXNativeTarget section */ 96 | 97 | /* Begin PBXProject section */ 98 | 460B72481B76D3E600BB5ED8 /* Project object */ = { 99 | isa = PBXProject; 100 | attributes = { 101 | LastSwiftUpdateCheck = 0720; 102 | LastUpgradeCheck = 0800; 103 | ORGANIZATIONNAME = "Andrew Breckenridge"; 104 | TargetAttributes = { 105 | 460B72501B76D3E600BB5ED8 = { 106 | CreatedOnToolsVersion = 7.0; 107 | LastSwiftMigration = 0800; 108 | }; 109 | }; 110 | }; 111 | buildConfigurationList = 460B724B1B76D3E600BB5ED8 /* Build configuration list for PBXProject "ZLSwipeableViewSwift" */; 112 | compatibilityVersion = "Xcode 3.2"; 113 | developmentRegion = English; 114 | hasScannedForEncodings = 0; 115 | knownRegions = ( 116 | en, 117 | ); 118 | mainGroup = 460B72471B76D3E600BB5ED8; 119 | productRefGroup = 460B72521B76D3E600BB5ED8 /* Products */; 120 | projectDirPath = ""; 121 | projectRoot = ""; 122 | targets = ( 123 | 460B72501B76D3E600BB5ED8 /* ZLSwipeableViewSwift */, 124 | ); 125 | }; 126 | /* End PBXProject section */ 127 | 128 | /* Begin PBXResourcesBuildPhase section */ 129 | 460B724F1B76D3E600BB5ED8 /* Resources */ = { 130 | isa = PBXResourcesBuildPhase; 131 | buildActionMask = 2147483647; 132 | files = ( 133 | ); 134 | runOnlyForDeploymentPostprocessing = 0; 135 | }; 136 | /* End PBXResourcesBuildPhase section */ 137 | 138 | /* Begin PBXSourcesBuildPhase section */ 139 | 460B724C1B76D3E600BB5ED8 /* Sources */ = { 140 | isa = PBXSourcesBuildPhase; 141 | buildActionMask = 2147483647; 142 | files = ( 143 | 466AFFEE1CEB8CD6006FF62A /* ViewManager.swift in Sources */, 144 | 466AFFF01CEB8CEB006FF62A /* Scheduler.swift in Sources */, 145 | 46C0F0351C68AC90004BE1B3 /* ZLSwipeableView.swift in Sources */, 146 | 466AFFEC1CEB8BA1006FF62A /* Direction.swift in Sources */, 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXSourcesBuildPhase section */ 151 | 152 | /* Begin XCBuildConfiguration section */ 153 | 460B72571B76D3E600BB5ED8 /* Debug */ = { 154 | isa = XCBuildConfiguration; 155 | buildSettings = { 156 | ALWAYS_SEARCH_USER_PATHS = NO; 157 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 158 | CLANG_CXX_LIBRARY = "libc++"; 159 | CLANG_ENABLE_MODULES = YES; 160 | CLANG_ENABLE_OBJC_ARC = YES; 161 | CLANG_WARN_BOOL_CONVERSION = YES; 162 | CLANG_WARN_CONSTANT_CONVERSION = YES; 163 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 164 | CLANG_WARN_EMPTY_BODY = YES; 165 | CLANG_WARN_ENUM_CONVERSION = YES; 166 | CLANG_WARN_INFINITE_RECURSION = YES; 167 | CLANG_WARN_INT_CONVERSION = YES; 168 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 169 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 170 | CLANG_WARN_UNREACHABLE_CODE = YES; 171 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 172 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 173 | COPY_PHASE_STRIP = NO; 174 | CURRENT_PROJECT_VERSION = 1; 175 | DEBUG_INFORMATION_FORMAT = dwarf; 176 | ENABLE_STRICT_OBJC_MSGSEND = YES; 177 | ENABLE_TESTABILITY = YES; 178 | GCC_C_LANGUAGE_STANDARD = gnu99; 179 | GCC_DYNAMIC_NO_PIC = NO; 180 | GCC_NO_COMMON_BLOCKS = YES; 181 | GCC_OPTIMIZATION_LEVEL = 0; 182 | GCC_PREPROCESSOR_DEFINITIONS = ( 183 | "DEBUG=1", 184 | "$(inherited)", 185 | ); 186 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 187 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 188 | GCC_WARN_UNDECLARED_SELECTOR = YES; 189 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 190 | GCC_WARN_UNUSED_FUNCTION = YES; 191 | GCC_WARN_UNUSED_VARIABLE = YES; 192 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 193 | MTL_ENABLE_DEBUG_INFO = YES; 194 | ONLY_ACTIVE_ARCH = YES; 195 | SDKROOT = iphoneos; 196 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 197 | TARGETED_DEVICE_FAMILY = "1,2"; 198 | VERSIONING_SYSTEM = "apple-generic"; 199 | VERSION_INFO_PREFIX = ""; 200 | }; 201 | name = Debug; 202 | }; 203 | 460B72581B76D3E600BB5ED8 /* Release */ = { 204 | isa = XCBuildConfiguration; 205 | buildSettings = { 206 | ALWAYS_SEARCH_USER_PATHS = NO; 207 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 208 | CLANG_CXX_LIBRARY = "libc++"; 209 | CLANG_ENABLE_MODULES = YES; 210 | CLANG_ENABLE_OBJC_ARC = YES; 211 | CLANG_WARN_BOOL_CONVERSION = YES; 212 | CLANG_WARN_CONSTANT_CONVERSION = YES; 213 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 214 | CLANG_WARN_EMPTY_BODY = YES; 215 | CLANG_WARN_ENUM_CONVERSION = YES; 216 | CLANG_WARN_INFINITE_RECURSION = YES; 217 | CLANG_WARN_INT_CONVERSION = YES; 218 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 219 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 220 | CLANG_WARN_UNREACHABLE_CODE = YES; 221 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 222 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 223 | COPY_PHASE_STRIP = NO; 224 | CURRENT_PROJECT_VERSION = 1; 225 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 226 | ENABLE_NS_ASSERTIONS = NO; 227 | ENABLE_STRICT_OBJC_MSGSEND = YES; 228 | GCC_C_LANGUAGE_STANDARD = gnu99; 229 | GCC_NO_COMMON_BLOCKS = YES; 230 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 231 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 232 | GCC_WARN_UNDECLARED_SELECTOR = YES; 233 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 234 | GCC_WARN_UNUSED_FUNCTION = YES; 235 | GCC_WARN_UNUSED_VARIABLE = YES; 236 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 237 | MTL_ENABLE_DEBUG_INFO = NO; 238 | SDKROOT = iphoneos; 239 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 240 | TARGETED_DEVICE_FAMILY = "1,2"; 241 | VALIDATE_PRODUCT = YES; 242 | VERSIONING_SYSTEM = "apple-generic"; 243 | VERSION_INFO_PREFIX = ""; 244 | }; 245 | name = Release; 246 | }; 247 | 460B725A1B76D3E600BB5ED8 /* Debug */ = { 248 | isa = XCBuildConfiguration; 249 | buildSettings = { 250 | CLANG_ENABLE_MODULES = YES; 251 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 252 | DEFINES_MODULE = YES; 253 | DYLIB_COMPATIBILITY_VERSION = 1; 254 | DYLIB_CURRENT_VERSION = 1; 255 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 256 | INFOPLIST_FILE = Info.plist; 257 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 258 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 259 | PRODUCT_BUNDLE_IDENTIFIER = tfw.ZLSwipeableViewSwift; 260 | PRODUCT_NAME = "$(TARGET_NAME)"; 261 | SKIP_INSTALL = YES; 262 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 263 | SWIFT_VERSION = 3.0; 264 | }; 265 | name = Debug; 266 | }; 267 | 460B725B1B76D3E600BB5ED8 /* Release */ = { 268 | isa = XCBuildConfiguration; 269 | buildSettings = { 270 | CLANG_ENABLE_MODULES = YES; 271 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; 272 | DEFINES_MODULE = YES; 273 | DYLIB_COMPATIBILITY_VERSION = 1; 274 | DYLIB_CURRENT_VERSION = 1; 275 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 276 | INFOPLIST_FILE = Info.plist; 277 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 278 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 279 | PRODUCT_BUNDLE_IDENTIFIER = tfw.ZLSwipeableViewSwift; 280 | PRODUCT_NAME = "$(TARGET_NAME)"; 281 | SKIP_INSTALL = YES; 282 | SWIFT_VERSION = 3.0; 283 | }; 284 | name = Release; 285 | }; 286 | /* End XCBuildConfiguration section */ 287 | 288 | /* Begin XCConfigurationList section */ 289 | 460B724B1B76D3E600BB5ED8 /* Build configuration list for PBXProject "ZLSwipeableViewSwift" */ = { 290 | isa = XCConfigurationList; 291 | buildConfigurations = ( 292 | 460B72571B76D3E600BB5ED8 /* Debug */, 293 | 460B72581B76D3E600BB5ED8 /* Release */, 294 | ); 295 | defaultConfigurationIsVisible = 0; 296 | defaultConfigurationName = Release; 297 | }; 298 | 460B72591B76D3E600BB5ED8 /* Build configuration list for PBXNativeTarget "ZLSwipeableViewSwift" */ = { 299 | isa = XCConfigurationList; 300 | buildConfigurations = ( 301 | 460B725A1B76D3E600BB5ED8 /* Debug */, 302 | 460B725B1B76D3E600BB5ED8 /* Release */, 303 | ); 304 | defaultConfigurationIsVisible = 0; 305 | defaultConfigurationName = Release; 306 | }; 307 | /* End XCConfigurationList section */ 308 | }; 309 | rootObject = 460B72481B76D3E600BB5ED8 /* Project object */; 310 | } 311 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwift/ZLSwipeableViewSwift.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwift/ZLSwipeableViewSwift.xcodeproj/xcshareddata/xcschemes/ZLSwipeableViewSwift.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 32 | 33 | 34 | 35 | 45 | 46 | 52 | 53 | 54 | 55 | 56 | 57 | 63 | 64 | 70 | 71 | 72 | 73 | 75 | 76 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Podfile: -------------------------------------------------------------------------------- 1 | target 'ZLSwipeableViewSwiftDemo' do 2 | pod 'UIColor+FlatColors' 3 | pod 'Cartography' 4 | # pod 'ReactiveUI' 5 | end 6 | 7 | target 'ZLSwipeableViewSwiftDemoTests' do 8 | pod 'UIColor+FlatColors' 9 | pod 'Cartography' 10 | # pod 'ReactiveUI' 11 | end 12 | 13 | use_frameworks! 14 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Podfile.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Cartography (1.0.1) 3 | - UIColor+FlatColors (0.0.2) 4 | 5 | DEPENDENCIES: 6 | - Cartography 7 | - UIColor+FlatColors 8 | 9 | SPEC CHECKSUMS: 10 | Cartography: c1460e99395b824d9d75360b0382faeb0b33dcd7 11 | UIColor+FlatColors: 6c699df7a575281794c688c64cee6c44fd1f93b4 12 | 13 | PODFILE CHECKSUM: 8e7c96524d011a1ab9a3ff3f064c099b04f6b392 14 | 15 | COCOAPODS: 1.1.1 16 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Align.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Align.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 17/02/15. 6 | // Copyright (c) 2015 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | private func makeEqual(_ attribute: (LayoutProxy) -> P, first: LayoutProxy, rest: [LayoutProxy]) -> [NSLayoutConstraint] { 16 | return rest.reduce([]) { acc, current in 17 | current.view.car_translatesAutoresizingMaskIntoConstraints = false 18 | 19 | return acc + [ attribute(first) == attribute(current) ] 20 | } 21 | } 22 | 23 | /// Aligns multiple views by their top edge. 24 | /// 25 | /// All views passed to this function will have 26 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 27 | /// 28 | /// - returns: An array of `NSLayoutConstraint` instances. 29 | /// 30 | @discardableResult public func align(top first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 31 | return makeEqual({ $0.top }, first: first, rest: rest) 32 | } 33 | 34 | /// Aligns multiple views by their right edge. 35 | /// 36 | /// All views passed to this function will have 37 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 38 | /// 39 | /// - returns: An array of `NSLayoutConstraint` instances. 40 | /// 41 | @discardableResult public func align(right first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 42 | return makeEqual({ $0.right }, first: first, rest: rest) 43 | } 44 | 45 | /// Aligns multiple views by their bottom edge. 46 | /// 47 | /// All views passed to this function will have 48 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 49 | /// 50 | /// - returns: An array of `NSLayoutConstraint` instances. 51 | /// 52 | @discardableResult public func align(bottom first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 53 | return makeEqual({ $0.bottom }, first: first, rest: rest) 54 | } 55 | 56 | /// Aligns multiple views by their left edge. 57 | /// 58 | /// All views passed to this function will have 59 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 60 | /// 61 | /// - returns: An array of `NSLayoutConstraint` instances. 62 | /// 63 | @discardableResult public func align(left first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 64 | return makeEqual({ $0.left }, first: first, rest: rest) 65 | } 66 | 67 | /// Aligns multiple views by their leading edge. 68 | /// 69 | /// All views passed to this function will have 70 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 71 | /// 72 | /// - returns: An array of `NSLayoutConstraint` instances. 73 | /// 74 | @discardableResult public func align(leading first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 75 | return makeEqual({ $0.leading }, first: first, rest: rest) 76 | } 77 | 78 | /// Aligns multiple vies by their trailing edge. 79 | /// 80 | /// All views passed to this function will have 81 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 82 | /// 83 | /// - returns: An array of `NSLayoutConstraint` instances. 84 | /// 85 | @discardableResult public func align(trailing first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 86 | return makeEqual({ $0.trailing }, first: first, rest: rest) 87 | } 88 | 89 | /// Aligns multiple views by their horizontal center. 90 | /// 91 | /// All views passed to this function will have 92 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 93 | /// 94 | /// - returns: An array of `NSLayoutConstraint` instances. 95 | /// 96 | @discardableResult public func align(centerX first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 97 | return makeEqual({ $0.centerX }, first: first, rest: rest) 98 | } 99 | 100 | /// Aligns multiple views by their vertical center. 101 | /// 102 | /// All views passed to this function will have 103 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 104 | /// 105 | /// - returns: An array of `NSLayoutConstraint` instances. 106 | /// 107 | @discardableResult public func align(centerY first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 108 | return makeEqual({ $0.centerY }, first: first, rest: rest) 109 | } 110 | 111 | /// Aligns multiple views by their baseline. 112 | /// 113 | /// All views passed to this function will have 114 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 115 | /// 116 | /// - returns: An array of `NSLayoutConstraint` instances. 117 | /// 118 | @discardableResult public func align(baseline first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 119 | return makeEqual({ $0.baseline }, first: first, rest: rest) 120 | } 121 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Coefficients.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Coefficients.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 17/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | #if os(iOS) 11 | import UIKit 12 | #endif 13 | 14 | public struct Coefficients { 15 | var multiplier: CGFloat = 1 16 | var constant: CGFloat = 0 17 | 18 | init() { } 19 | 20 | init(_ multiplier: CGFloat, _ constant: CGFloat) { 21 | self.constant = constant 22 | self.multiplier = multiplier 23 | } 24 | } 25 | 26 | // MARK: Addition 27 | 28 | public func + (c: CGFloat, rhs: Coefficients) -> Coefficients { 29 | return Coefficients(rhs.multiplier, rhs.constant + c) 30 | } 31 | 32 | public func + (lhs: Coefficients, rhs: CGFloat) -> Coefficients { 33 | return rhs + lhs 34 | } 35 | 36 | // MARK: Subtraction 37 | 38 | public func - (c: CGFloat, rhs: Coefficients) -> Coefficients { 39 | return Coefficients(rhs.multiplier, rhs.constant - c) 40 | } 41 | 42 | public func - (lhs: Coefficients, rhs: CGFloat) -> Coefficients { 43 | return rhs - lhs 44 | } 45 | 46 | // MARK: Multiplication 47 | 48 | public func * (m: CGFloat, rhs: Coefficients) -> Coefficients { 49 | return Coefficients(rhs.multiplier * m, rhs.constant * m) 50 | } 51 | 52 | public func * (lhs: Coefficients, rhs: CGFloat) -> Coefficients { 53 | return rhs * lhs 54 | } 55 | 56 | // MARK: Division 57 | 58 | public func / (m: CGFloat, rhs: Coefficients) -> Coefficients { 59 | return Coefficients(rhs.multiplier / m, rhs.constant / m) 60 | } 61 | 62 | public func / (lhs: Coefficients, rhs: CGFloat) -> Coefficients { 63 | return rhs / lhs 64 | } 65 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Compound.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Compound.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 18/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | public protocol Compound { 16 | var context: Context { get } 17 | var properties: [Property] { get } 18 | } 19 | 20 | /// Compound properties conforming to this protocol can use the `==` operator 21 | /// with other compound properties of the same type. 22 | public protocol RelativeCompoundEquality : Compound { } 23 | 24 | /// Declares a property equal to a the result of an expression. 25 | /// 26 | /// - parameter lhs: The affected property. The associated view will have 27 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 28 | /// - parameter rhs: The expression. 29 | /// 30 | /// - returns: An `NSLayoutConstraint`. 31 | /// 32 | @discardableResult public func == (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { 33 | return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value) 34 | } 35 | 36 | /// Declares a property equal to another compound property. 37 | /// 38 | /// - parameter lhs: The affected property. The associated view will have 39 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 40 | /// - parameter rhs: The other property. 41 | /// 42 | @discardableResult public func == (lhs: P, rhs: P) -> [NSLayoutConstraint] { 43 | return lhs.context.addConstraint(lhs, to: rhs) 44 | } 45 | 46 | /// Compound properties conforming to this protocol can use the `<=` and `>=` 47 | /// operators with other compound properties of the same type. 48 | public protocol RelativeCompoundInequality : Compound { } 49 | 50 | /// Declares a property less than or equal to another compound property. 51 | /// 52 | /// - parameter lhs: The affected property. The associated view will have 53 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 54 | /// - parameter rhs: The other property. 55 | /// 56 | /// - returns: An `NSLayoutConstraint`. 57 | /// 58 | @discardableResult public func <= (lhs: P, rhs: P) -> [NSLayoutConstraint] { 59 | return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.lessThanOrEqual) 60 | } 61 | 62 | /// Declares a property greater than or equal to another compound property. 63 | /// 64 | /// - parameter lhs: The affected property. The associated view will have 65 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 66 | /// - parameter rhs: The other property. 67 | /// 68 | /// - returns: An `NSLayoutConstraint`. 69 | /// 70 | @discardableResult public func >= (lhs: P, rhs: P) -> [NSLayoutConstraint] { 71 | return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.greaterThanOrEqual) 72 | } 73 | 74 | /// Declares a property less than or equal to the result of an expression. 75 | /// 76 | /// - parameter lhs: The affected property. The associated view will have 77 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 78 | /// - parameter rhs: The other property. 79 | /// 80 | /// - returns: An `NSLayoutConstraint`. 81 | /// 82 | @discardableResult public func <= (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { 83 | return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value, relation: NSLayoutRelation.lessThanOrEqual) 84 | } 85 | 86 | /// Declares a property greater than or equal to the result of an expression. 87 | /// 88 | /// - parameter lhs: The affected property. The associated view will have 89 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 90 | /// - parameter rhs: The other property. 91 | /// 92 | /// - returns: An `NSLayoutConstraint`. 93 | /// 94 | @discardableResult public func >= (lhs: P, rhs: Expression

) -> [NSLayoutConstraint] { 95 | return lhs.context.addConstraint(lhs, coefficients: rhs.coefficients, to: rhs.value, relation: NSLayoutRelation.greaterThanOrEqual) 96 | } 97 | 98 | #if os(iOS) || os(tvOS) 99 | 100 | /// Declares a property equal to a layout support. 101 | /// 102 | /// - parameter lhs: The affected property. The associated view will have 103 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 104 | /// - parameter rhs: The layout support. 105 | /// 106 | /// - returns: An `NSLayoutConstraint`. 107 | /// 108 | 109 | @discardableResult public func == (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { 110 | return lhs.context.addConstraint(lhs, to: rhs) 111 | } 112 | 113 | /// Declares a property equal to the result of a layout support expression. 114 | /// 115 | /// - parameter lhs: The affected property. The associated view will have 116 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 117 | /// - parameter rhs: The layout support expression. 118 | /// 119 | /// - returns: An `NSLayoutConstraint`. 120 | /// 121 | 122 | @discardableResult public func == (lhs: P, rhs: Expression) -> NSLayoutConstraint { 123 | return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0]) 124 | } 125 | 126 | /// Declares a property greater than or equal to a layout support. 127 | /// 128 | /// - parameter lhs: The affected property. The associated view will have 129 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 130 | /// - parameter rhs: The layout support. 131 | /// 132 | /// - returns: An `NSLayoutConstraint`. 133 | /// 134 | 135 | @discardableResult public func >= (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { 136 | return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.greaterThanOrEqual) 137 | } 138 | 139 | /// Declares a property less than or equal to a layout support. 140 | /// 141 | /// - parameter lhs: The affected property. The associated view will have 142 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 143 | /// - parameter rhs: The layout support. 144 | /// 145 | /// - returns: An `NSLayoutConstraint`. 146 | /// 147 | 148 | @discardableResult public func <= (lhs: P, rhs: LayoutSupport) -> NSLayoutConstraint { 149 | return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.lessThanOrEqual) 150 | } 151 | 152 | /// Declares a property greater than or equal to the result of a layout support expression. 153 | /// 154 | /// - parameter lhs: The affected property. The associated view will have 155 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 156 | /// - parameter rhs: The layout support. 157 | /// 158 | /// - returns: An `NSLayoutConstraint`. 159 | /// 160 | 161 | @discardableResult public func >= (lhs: P, rhs: Expression) -> NSLayoutConstraint { 162 | return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.greaterThanOrEqual) 163 | } 164 | 165 | /// Declares a property less than or equal to the result of a layout support expression. 166 | /// 167 | /// - parameter lhs: The affected property. The associated view will have 168 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 169 | /// - parameter rhs: The layout support. 170 | /// 171 | /// - returns: An `NSLayoutConstraint`. 172 | /// 173 | 174 | @discardableResult public func <= (lhs: P, rhs: Expression) -> NSLayoutConstraint { 175 | return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.lessThanOrEqual) 176 | } 177 | 178 | #endif 179 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Constrain.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Constrain.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 30/09/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | /// Updates the constraints of a single view. 12 | /// 13 | /// - parameter view: The view to layout. 14 | /// - parameter replace: The `ConstraintGroup` whose constraints should be 15 | /// replaced. 16 | /// - parameter block: A block that declares the layout for `view`. 17 | /// 18 | @discardableResult public func constrain(_ view: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy) -> ()) -> ConstraintGroup { 19 | let constraintGroup = group ?? ConstraintGroup() 20 | let context = Context() 21 | block(LayoutProxy(context, view)) 22 | constraintGroup.replaceConstraints(context.constraints) 23 | 24 | return constraintGroup 25 | } 26 | 27 | /// Updates the constraints of two views. 28 | /// 29 | /// - parameter view1: A view to layout. 30 | /// - parameter view2: A view to layout. 31 | /// - parameter replace: The `ConstraintGroup` whose constraints should be 32 | /// replaced. 33 | /// - parameter block: A block that declares the layout for the views. 34 | /// 35 | @discardableResult public func constrain(_ view1: View, _ view2: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { 36 | let constraintGroup = group ?? ConstraintGroup() 37 | let context = Context() 38 | block(LayoutProxy(context, view1), LayoutProxy(context, view2)) 39 | constraintGroup.replaceConstraints(context.constraints) 40 | 41 | return constraintGroup 42 | } 43 | 44 | /// Updates the constraints of three views. 45 | /// 46 | /// - parameter view1: A view to layout. 47 | /// - parameter view2: A view to layout. 48 | /// - parameter view3: A view to layout. 49 | /// - parameter replace: The `ConstraintGroup` whose constraints should be 50 | /// replaced. 51 | /// - parameter block: A block that declares the layout for the views. 52 | /// 53 | @discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { 54 | let constraintGroup = group ?? ConstraintGroup() 55 | let context = Context() 56 | block(LayoutProxy(context, view1), LayoutProxy(context, view2), LayoutProxy(context, view3)) 57 | constraintGroup.replaceConstraints(context.constraints) 58 | 59 | return constraintGroup 60 | } 61 | 62 | /// Updates the constraints of four views. 63 | /// 64 | /// - parameter view1: A view to layout. 65 | /// - parameter view2: A view to layout. 66 | /// - parameter view3: A view to layout. 67 | /// - parameter view4: A view to layout. 68 | /// - parameter replace: The `ConstraintGroup` whose constraints should be 69 | /// replaced. 70 | /// - parameter block: A block that declares the layout for the views. 71 | /// 72 | @discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, _ view4: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { 73 | let constraintGroup = group ?? ConstraintGroup() 74 | let context = Context() 75 | block(LayoutProxy(context, view1), LayoutProxy(context, view2), LayoutProxy(context, view3), LayoutProxy(context, view4)) 76 | constraintGroup.replaceConstraints(context.constraints) 77 | 78 | return constraintGroup 79 | } 80 | 81 | /// Updates the constraints of five views. 82 | /// 83 | /// - parameter view1: A view to layout. 84 | /// - parameter view2: A view to layout. 85 | /// - parameter view3: A view to layout. 86 | /// - parameter view4: A view to layout. 87 | /// - parameter view5: A view to layout. 88 | /// - parameter replace: The `ConstraintGroup` whose constraints should be 89 | /// replaced. 90 | /// - parameter block: A block that declares the layout for the views. 91 | /// 92 | @discardableResult public func constrain(_ view1: View, _ view2: View, _ view3: View, _ view4: View, _ view5: View, replace group: ConstraintGroup? = nil, block: (LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy, LayoutProxy) -> ()) -> ConstraintGroup { 93 | let constraintGroup = group ?? ConstraintGroup() 94 | let context = Context() 95 | block(LayoutProxy(context, view1), LayoutProxy(context, view2), LayoutProxy(context, view3), LayoutProxy(context, view4), LayoutProxy(context, view5)) 96 | constraintGroup.replaceConstraints(context.constraints) 97 | 98 | return constraintGroup 99 | } 100 | 101 | /// Updates the constraints of an array of views. 102 | /// 103 | /// - parameter views: The views to layout. 104 | /// - parameter replace: The `ConstraintGroup` whose constraints should be 105 | /// replaced. 106 | /// - parameter block: A block that declares the layout for `views`. 107 | /// 108 | @discardableResult public func constrain(_ views: [View], replace group: ConstraintGroup? = nil, block: ([LayoutProxy]) -> ()) -> ConstraintGroup { 109 | let constraintGroup = group ?? ConstraintGroup() 110 | let context = Context() 111 | block(views.map({ LayoutProxy(context, $0) })) 112 | constraintGroup.replaceConstraints(context.constraints) 113 | 114 | return constraintGroup 115 | } 116 | 117 | /// Updates the constraints of a dictionary of views. 118 | /// 119 | /// - parameter views: The views to layout. 120 | /// - parameter replace: The `ConstraintGroup` whose constraints should be 121 | /// replaced. 122 | /// - parameter block: A block that declares the layout for `views`. 123 | /// 124 | @discardableResult public func constrain(_ views: [T: View], replace group: ConstraintGroup? = nil, block: (([T : LayoutProxy]) -> ())) -> ConstraintGroup { 125 | let constraintGroup = group ?? ConstraintGroup() 126 | let context = Context() 127 | let proxies = views.map { ($0, LayoutProxy(context, $1)) } 128 | var dict = [T:LayoutProxy]() 129 | 130 | proxies.forEach { 131 | dict[$0.0] = $0.1 132 | } 133 | 134 | block(dict) 135 | constraintGroup.replaceConstraints(context.constraints) 136 | 137 | return constraintGroup 138 | } 139 | 140 | /// Removes all constraints for a group. 141 | /// 142 | /// - parameter clear: The `ConstraintGroup` whose constraints should be removed. 143 | /// 144 | public func constrain(clear group: ConstraintGroup) { 145 | group.replaceConstraints([]) 146 | } 147 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Constraint.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Constraint.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 06/10/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | internal class Constraint { 16 | // Set to weak to avoid a retain cycle on the associated view. 17 | weak var view: View? 18 | let layoutConstraint: NSLayoutConstraint 19 | 20 | func install() { 21 | view?.addConstraint(layoutConstraint) 22 | } 23 | 24 | func uninstall() { 25 | view?.removeConstraint(layoutConstraint) 26 | } 27 | 28 | init(view: View, layoutConstraint: NSLayoutConstraint) { 29 | self.view = view 30 | self.layoutConstraint = layoutConstraint 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/ConstraintGroup.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ConstraintGroup.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 22/01/15. 6 | // Copyright (c) 2015 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public class ConstraintGroup { 12 | private var constraints: [Constraint] = [] 13 | 14 | @available(OSX, introduced: 10.10) 15 | @available(iOS, introduced: 8.0) 16 | public var active: Bool { 17 | get { 18 | return constraints 19 | .map { $0.layoutConstraint.isActive } 20 | .reduce(true) { $0 && $1 } 21 | } 22 | set { 23 | for constraint in constraints { 24 | constraint.layoutConstraint.isActive = newValue 25 | } 26 | } 27 | } 28 | 29 | public init() { 30 | 31 | } 32 | 33 | internal func replaceConstraints(_ constraints: [Constraint]) { 34 | for constraint in self.constraints { 35 | constraint.uninstall() 36 | } 37 | 38 | self.constraints = constraints 39 | 40 | for constraint in self.constraints { 41 | constraint.install() 42 | } 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Context.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Context.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 06/10/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | public class Context { 16 | internal var constraints: [Constraint] = [] 17 | 18 | #if os(iOS) || os(tvOS) 19 | 20 | internal func addConstraint(_ from: Property, to: LayoutSupport, coefficients: Coefficients = Coefficients(), relation: NSLayoutRelation = .equal) -> NSLayoutConstraint { 21 | from.view.car_translatesAutoresizingMaskIntoConstraints = false 22 | 23 | let layoutConstraint = NSLayoutConstraint(item: from.view, 24 | attribute: from.attribute, 25 | relatedBy: relation, 26 | toItem: to.layoutGuide, 27 | attribute: to.attribute, 28 | multiplier: CGFloat(coefficients.multiplier), 29 | constant: CGFloat(coefficients.constant)) 30 | 31 | var view = from.view 32 | while let superview = view.superview { 33 | view = superview 34 | } 35 | constraints.append(Constraint(view: view, layoutConstraint: layoutConstraint)) 36 | 37 | return layoutConstraint 38 | } 39 | 40 | #endif 41 | 42 | internal func addConstraint(_ from: Property, to: Property? = nil, coefficients: Coefficients = Coefficients(), relation: NSLayoutRelation = .equal) -> NSLayoutConstraint { 43 | 44 | from.view.car_translatesAutoresizingMaskIntoConstraints = false 45 | 46 | let layoutConstraint = NSLayoutConstraint(item: from.view, 47 | attribute: from.attribute, 48 | relatedBy: relation, 49 | toItem: to?.view, 50 | attribute: to?.attribute ?? .notAnAttribute, 51 | multiplier: CGFloat(coefficients.multiplier), 52 | constant: CGFloat(coefficients.constant)) 53 | 54 | if let to = to { 55 | if let common = closestCommonAncestor(from.view, b: to.view ) { 56 | constraints.append(Constraint(view: common, layoutConstraint: layoutConstraint)) 57 | } else { 58 | fatalError("No common superview found between \(from.view) and \(to.view)") 59 | } 60 | } else { 61 | constraints.append(Constraint(view: from.view, layoutConstraint: layoutConstraint)) 62 | } 63 | 64 | return layoutConstraint 65 | } 66 | 67 | internal func addConstraint(_ from: Compound, coefficients: [Coefficients]? = nil, to: Compound? = nil, relation: NSLayoutRelation = NSLayoutRelation.equal) -> [NSLayoutConstraint] { 68 | var results: [NSLayoutConstraint] = [] 69 | 70 | for i in 0.. NSLayoutConstraint) -> [NSLayoutConstraint] { 18 | rest.last?.view.car_translatesAutoresizingMaskIntoConstraints = false 19 | 20 | return rest.reduce(([], first)) { (acc, current) -> Accumulator in 21 | let (constraints, previous) = acc 22 | 23 | return (constraints + [ combine(previous, current) ], current) 24 | }.0 25 | } 26 | 27 | /// Distributes multiple views horizontally. 28 | /// 29 | /// All views passed to this function will have 30 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 31 | /// 32 | /// - parameter amount: The distance between the views. 33 | /// - parameter views: The views to distribute. 34 | /// 35 | /// - returns: An array of `NSLayoutConstraint` instances. 36 | /// 37 | @discardableResult public func distribute(by amount: CGFloat, horizontally first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 38 | return reduce(first, rest: rest) { $0.trailing == $1.leading - amount } 39 | } 40 | 41 | /// Distributes multiple views horizontally from left to right. 42 | /// 43 | /// All views passed to this function will have 44 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 45 | /// 46 | /// - parameter amount: The distance between the views. 47 | /// - parameter views: The views to distribute. 48 | /// 49 | /// - returns: An array of `NSLayoutConstraint` instances. 50 | /// 51 | @discardableResult public func distribute(by amount: CGFloat, leftToRight first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 52 | return reduce(first, rest: rest) { $0.right == $1.left - amount } 53 | } 54 | 55 | /// Distributes multiple views vertically. 56 | /// 57 | /// All views passed to this function will have 58 | /// their `translatesAutoresizingMaskIntoConstraints` properties set to `false`. 59 | /// 60 | /// - parameter amount: The distance between the views. 61 | /// - parameter views: The views to distribute. 62 | /// 63 | /// - returns: An array of `NSLayoutConstraint` instances. 64 | /// 65 | @discardableResult public func distribute(by amount: CGFloat, vertically first: LayoutProxy, _ rest: LayoutProxy...) -> [NSLayoutConstraint] { 66 | return reduce(first, rest: rest) { $0.bottom == $1.top - amount } 67 | } 68 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Edge.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Edge.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 17/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | public struct Edge : Property, RelativeEquality, RelativeInequality, Addition, Multiplication { 16 | public let attribute: NSLayoutAttribute 17 | public let context: Context 18 | public let view: View 19 | 20 | internal init(_ context: Context, _ view: View, _ attribute: NSLayoutAttribute) { 21 | self.attribute = attribute 22 | self.context = context 23 | self.view = view 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Edges.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Edges.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 19/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | public struct Edges: Compound, RelativeCompoundEquality, RelativeCompoundInequality { 16 | public let context: Context 17 | public let properties: [Property] 18 | 19 | internal init(_ context: Context, _ properties: [Property]) { 20 | self.context = context 21 | self.properties = properties 22 | } 23 | } 24 | 25 | /// Insets all edges. 26 | /// 27 | /// - parameter edges: The edges to inset. 28 | /// - parameter all: The amount by which to inset all edges, in points. 29 | /// 30 | /// - returns: A new expression with the inset edges. 31 | /// 32 | public func inset(_ edges: Edges, _ all: CGFloat) -> Expression { 33 | return inset(edges, all, all, all, all) 34 | } 35 | 36 | /// Insets the horizontal and vertical edges. 37 | /// 38 | /// - parameter edges: The edges to inset. 39 | /// - parameter horizontal: The amount by which to inset the horizontal edges, in 40 | /// points. 41 | /// - parameter vertical: The amount by which to inset the vertical edges, in 42 | /// points. 43 | /// 44 | /// - returns: A new expression with the inset edges. 45 | /// 46 | public func inset(_ edges: Edges, _ horizontal: CGFloat, _ vertical: CGFloat) -> Expression { 47 | return inset(edges, vertical, horizontal, vertical, horizontal) 48 | } 49 | 50 | /// Insets edges individually. 51 | /// 52 | /// - parameter edges: The edges to inset. 53 | /// - parameter top: The amount by which to inset the top edge, in points. 54 | /// - parameter leading: The amount by which to inset the leading edge, in points. 55 | /// - parameter bottom: The amount by which to inset the bottom edge, in points. 56 | /// - parameter trailing: The amount by which to inset the trailing edge, in points. 57 | /// 58 | /// - returns: A new expression with the inset edges. 59 | /// 60 | public func inset(_ edges: Edges, _ top: CGFloat, _ leading: CGFloat, _ bottom: CGFloat, _ trailing: CGFloat) -> Expression { 61 | return Expression(edges, [ 62 | Coefficients(1, top), 63 | Coefficients(1, leading), 64 | Coefficients(1, -bottom), 65 | Coefficients(1, -trailing) 66 | ]) 67 | } 68 | 69 | #if os(iOS) || os(tvOS) 70 | /// Insets edges individually with UIEdgeInset. 71 | /// 72 | /// - parameter edges: The edges to inset. 73 | /// - parameter insets: The amounts by which to inset all edges, in points via UIEdgeInsets. 74 | /// 75 | /// - returns: A new expression with the inset edges. 76 | /// 77 | public func inset(_ edges: Edges, _ insets: UIEdgeInsets) -> Expression { 78 | return inset(edges, insets.top, insets.left, insets.bottom, insets.right) 79 | } 80 | #endif 81 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Expression.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Expression.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 17/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct Expression { 12 | let value: T 13 | var coefficients: [Coefficients] 14 | 15 | init(_ value: T, _ coefficients: [Coefficients]) { 16 | assert(coefficients.count > 0) 17 | 18 | self.value = value 19 | self.coefficients = coefficients 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Extensions.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Extensions.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 22/01/15. 6 | // Copyright (c) 2015 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | internal extension Dictionary { 16 | init(_ pairs: [Element]) { 17 | self.init() 18 | 19 | for (key, value) in pairs { 20 | self[key] = value 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/LayoutProxy.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LayoutProxy.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 17/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | public struct LayoutProxy { 12 | /// The width of the view. 13 | public var width: Dimension { 14 | return Dimension(context, view, .width) 15 | } 16 | 17 | /// The height of the view. 18 | public var height: Dimension { 19 | return Dimension(context, view, .height) 20 | } 21 | 22 | /// The size of the view. This property affects both `width` and `height`. 23 | public var size: Size { 24 | return Size(context, [ 25 | Dimension(context, view, .width), 26 | Dimension(context, view, .height) 27 | ]) 28 | } 29 | 30 | /// The top edge of the view. 31 | public var top: Edge { 32 | return Edge(context, view, .top) 33 | } 34 | 35 | /// The right edge of the view. 36 | public var right: Edge { 37 | return Edge(context, view, .right) 38 | } 39 | 40 | /// The bottom edge of the view. 41 | public var bottom: Edge { 42 | return Edge(context, view, .bottom) 43 | } 44 | 45 | /// The left edge of the view. 46 | public var left: Edge { 47 | return Edge(context, view, .left) 48 | } 49 | 50 | /// All edges of the view. This property affects `top`, `bottom`, `leading` 51 | /// and `trailing`. 52 | public var edges: Edges { 53 | return Edges(context, [ 54 | Edge(context, view, .top), 55 | Edge(context, view, .leading), 56 | Edge(context, view, .bottom), 57 | Edge(context, view, .trailing) 58 | ]) 59 | } 60 | 61 | /// The leading edge of the view. 62 | public var leading: Edge { 63 | return Edge(context, view, .leading) 64 | } 65 | 66 | /// The trailing edge of the view. 67 | public var trailing: Edge { 68 | return Edge(context, view, .trailing) 69 | } 70 | 71 | /// The horizontal center of the view. 72 | public var centerX: Edge { 73 | return Edge(context, view, .centerX) 74 | } 75 | 76 | /// The vertical center of the view. 77 | public var centerY: Edge { 78 | return Edge(context, view, .centerY) 79 | } 80 | 81 | /// The center point of the view. This property affects `centerX` and 82 | /// `centerY`. 83 | public var center: Point { 84 | return Point(context, [ 85 | Edge(context, view, .centerX), 86 | Edge(context, view, .centerY) 87 | ]) 88 | } 89 | 90 | /// The baseline of the view. 91 | public var baseline: Edge { 92 | return Edge(context, view, .lastBaseline) 93 | } 94 | 95 | /// The last baseline of the view. 96 | public var lastBaseline: Edge { 97 | return Edge(context, view, .lastBaseline) 98 | } 99 | 100 | #if os(iOS) || os(tvOS) 101 | /// The first baseline of the view. iOS exclusive. 102 | @available(iOS, introduced: 8.0) 103 | public var firstBaseline: Edge { 104 | return Edge(context, view, .firstBaseline) 105 | } 106 | 107 | /// All edges of the view with their respective margins. This property 108 | /// affects `topMargin`, `bottomMargin`, `leadingMargin` and 109 | /// `trailingMargin`. 110 | @available(iOS, introduced: 8.0) 111 | public var edgesWithinMargins: Edges { 112 | return Edges(context, [ 113 | Edge(context, view, .topMargin), 114 | Edge(context, view, .leadingMargin), 115 | Edge(context, view, .bottomMargin), 116 | Edge(context, view, .trailingMargin) 117 | ]) 118 | } 119 | 120 | /// The left margin of the view. iOS exclusive. 121 | @available(iOS, introduced: 8.0) 122 | public var leftMargin: Edge { 123 | return Edge(context, view, .leftMargin) 124 | } 125 | 126 | /// The right margin of the view. iOS exclusive. 127 | @available(iOS, introduced: 8.0) 128 | public var rightMargin: Edge { 129 | return Edge(context, view, .rightMargin) 130 | } 131 | 132 | /// The top margin of the view. iOS exclusive. 133 | @available(iOS, introduced: 8.0) 134 | public var topMargin: Edge { 135 | return Edge(context, view, .topMargin) 136 | } 137 | 138 | /// The bottom margin of the view. iOS exclusive. 139 | @available(iOS, introduced: 8.0) 140 | public var bottomMargin: Edge { 141 | return Edge(context, view, .bottomMargin) 142 | } 143 | 144 | /// The leading margin of the view. iOS exclusive. 145 | @available(iOS, introduced: 8.0) 146 | public var leadingMargin: Edge { 147 | return Edge(context, view, .leadingMargin) 148 | } 149 | 150 | /// The trailing margin of the view. iOS exclusive. 151 | @available(iOS, introduced: 8.0) 152 | public var trailingMargin: Edge { 153 | return Edge(context, view, .trailingMargin) 154 | } 155 | 156 | /// The horizontal center within the margins of the view. iOS exclusive. 157 | @available(iOS, introduced: 8.0) 158 | public var centerXWithinMargins: Edge { 159 | return Edge(context, view, .centerXWithinMargins) 160 | } 161 | 162 | /// The vertical center within the margins of the view. iOS exclusive. 163 | @available(iOS, introduced: 8.0) 164 | public var centerYWithinMargins: Edge { 165 | return Edge(context, view, .centerYWithinMargins) 166 | } 167 | 168 | /// The center point within the margins of the view. This property affects 169 | /// `centerXWithinMargins` and `centerYWithinMargins`. iOS exclusive. 170 | @available(iOS, introduced: 8.0) 171 | public var centerWithinMargins: Point { 172 | return Point(context, [ 173 | Edge(context, view, .centerXWithinMargins), 174 | Edge(context, view, .centerYWithinMargins) 175 | ]) 176 | } 177 | #endif 178 | 179 | internal let context: Context 180 | 181 | internal let view: View 182 | 183 | /// The superview of the view, if it exists. 184 | public var superview: LayoutProxy? { 185 | if let superview = view.superview { 186 | return LayoutProxy(context, superview) 187 | } else { 188 | return nil 189 | } 190 | } 191 | 192 | init(_ context: Context, _ view: View) { 193 | self.context = context 194 | self.view = view 195 | } 196 | } 197 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/LayoutSupport.swift: -------------------------------------------------------------------------------- 1 | // 2 | // LayoutSupport.swift 3 | // Cartography 4 | // 5 | // Created by Timothy Chilvers on 30/03/2016. 6 | // Copyright © 2016 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if os(iOS) || os(tvOS) 12 | import UIKit 13 | 14 | public struct LayoutSupport { 15 | let layoutGuide : UILayoutSupport 16 | let attribute : NSLayoutAttribute 17 | } 18 | 19 | public extension UIViewController { 20 | 21 | var topLayoutGuideCartography : LayoutSupport { 22 | get { 23 | return LayoutSupport(layoutGuide: self.topLayoutGuide, attribute: .bottom) 24 | } 25 | } 26 | 27 | var bottomLayoutGuideCartography : LayoutSupport { 28 | get { 29 | return LayoutSupport(layoutGuide: self.bottomLayoutGuide, attribute: .top) 30 | } 31 | } 32 | } 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Point.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Point.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 18/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | public struct Point: Compound, RelativeCompoundEquality, RelativeCompoundInequality { 16 | public let context: Context 17 | public let properties: [Property] 18 | 19 | internal init(_ context: Context, _ properties: [Property]) { 20 | self.context = context 21 | self.properties = properties 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Priority.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Priority.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 18/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | 12 | public typealias LayoutPriority = UILayoutPriority 13 | #else 14 | import AppKit 15 | 16 | public typealias LayoutPriority = NSLayoutPriority 17 | #endif 18 | 19 | precedencegroup CarthographyPriorityPrecedence { 20 | lowerThan: ComparisonPrecedence 21 | higherThan: AssignmentPrecedence 22 | } 23 | 24 | infix operator ~: CarthographyPriorityPrecedence 25 | 26 | /// Sets the priority for a constraint. 27 | /// 28 | /// - parameter lhs: The constraint to update. 29 | /// - parameter rhs: The new priority. 30 | /// 31 | /// - returns: The same constraint with its priority updated. 32 | /// 33 | @discardableResult public func ~ (lhs: NSLayoutConstraint, rhs: LayoutPriority) -> NSLayoutConstraint { 34 | lhs.priority = rhs 35 | 36 | return lhs 37 | } 38 | 39 | /// Sets the priority for multiple constraints. 40 | /// 41 | /// - parameter lhs: An array of `NSLayoutConstraint` instances. 42 | /// - parameter rhs: The new priority. 43 | /// 44 | /// - returns: The same constraints with their priorities updated. 45 | /// 46 | @discardableResult public func ~ (lhs: [NSLayoutConstraint], rhs: LayoutPriority) -> [NSLayoutConstraint] { 47 | return lhs.map { 48 | $0 ~ rhs 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Property.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Property.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 17/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | public protocol Property { 16 | var attribute: NSLayoutAttribute { get } 17 | var context: Context { get } 18 | var view: View { get } 19 | } 20 | 21 | // MARK: Equality 22 | 23 | /// Properties conforming to this protocol can use the `==` operator with 24 | /// numerical constants. 25 | public protocol NumericalEquality : Property { } 26 | 27 | /// Declares a property equal to a numerical constant. 28 | /// 29 | /// - parameter lhs: The affected property. The associated view will have 30 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 31 | /// - parameter rhs: The numerical constant. 32 | /// 33 | /// - returns: An `NSLayoutConstraint`. 34 | /// 35 | @discardableResult public func == (lhs: NumericalEquality, rhs: CGFloat) -> NSLayoutConstraint { 36 | return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs)) 37 | } 38 | 39 | /// Properties conforming to this protocol can use the `==` operator with other 40 | /// properties of the same type. 41 | public protocol RelativeEquality : Property { } 42 | 43 | /// Declares a property equal to a the result of an expression. 44 | /// 45 | /// - parameter lhs: The affected property. The associated view will have 46 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 47 | /// - parameter rhs: The expression. 48 | /// 49 | /// - returns: An `NSLayoutConstraint`. 50 | /// 51 | @discardableResult public func == (lhs: P, rhs: Expression

) -> NSLayoutConstraint { 52 | return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0]) 53 | } 54 | 55 | /// Declares a property equal to another property. 56 | /// 57 | /// - parameter lhs: The affected property. The associated view will have 58 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 59 | /// - parameter rhs: The other property. 60 | /// 61 | @discardableResult public func == (lhs: P, rhs: P) -> NSLayoutConstraint { 62 | return lhs.context.addConstraint(lhs, to: rhs) 63 | } 64 | 65 | // MARK: Inequality 66 | 67 | /// Properties conforming to this protocol can use the `<=` and `>=` operators 68 | /// with numerical constants. 69 | public protocol NumericalInequality : Property { } 70 | 71 | /// Declares a property less than or equal to a numerical constant. 72 | /// 73 | /// - parameter lhs: The affected property. The associated view will have 74 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 75 | /// - parameter rhs: The numerical constant. 76 | /// 77 | /// - returns: An `NSLayoutConstraint`. 78 | /// 79 | @discardableResult public func <= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint { 80 | return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs), relation: NSLayoutRelation.lessThanOrEqual) 81 | } 82 | 83 | /// Declares a property greater than or equal to a numerical constant. 84 | /// 85 | /// - parameter lhs: The affected property. The associated view will have 86 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 87 | /// - parameter rhs: The numerical constant. 88 | /// 89 | /// - returns: An `NSLayoutConstraint`. 90 | /// 91 | @discardableResult public func >= (lhs: NumericalInequality, rhs: CGFloat) -> NSLayoutConstraint { 92 | return lhs.context.addConstraint(lhs, coefficients: Coefficients(1, rhs), relation: NSLayoutRelation.greaterThanOrEqual) 93 | } 94 | 95 | /// Properties conforming to this protocol can use the `<=` and `>=` operators 96 | /// with other properties of the same type. 97 | public protocol RelativeInequality : Property { } 98 | 99 | /// Declares a property less than or equal to another property. 100 | /// 101 | /// - parameter lhs: The affected property. The associated view will have 102 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 103 | /// - parameter rhs: The other property. 104 | /// 105 | /// - returns: An `NSLayoutConstraint`. 106 | /// 107 | @discardableResult public func <= (lhs: P, rhs: P) -> NSLayoutConstraint { 108 | return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.lessThanOrEqual) 109 | } 110 | 111 | /// Declares a property greater than or equal to another property. 112 | /// 113 | /// - parameter lhs: The affected property. The associated view will have 114 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 115 | /// - parameter rhs: The other property. 116 | /// 117 | /// - returns: An `NSLayoutConstraint`. 118 | /// 119 | @discardableResult public func >= (lhs: P, rhs: P) -> NSLayoutConstraint { 120 | return lhs.context.addConstraint(lhs, to: rhs, relation: NSLayoutRelation.greaterThanOrEqual) 121 | } 122 | 123 | /// Declares a property less than or equal to the result of an expression. 124 | /// 125 | /// - parameter lhs: The affected property. The associated view will have 126 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 127 | /// - parameter rhs: The other property. 128 | /// 129 | /// - returns: An `NSLayoutConstraint`. 130 | /// 131 | @discardableResult public func <= (lhs: P, rhs: Expression

) -> NSLayoutConstraint { 132 | return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.lessThanOrEqual) 133 | } 134 | 135 | /// Declares a property greater than or equal to the result of an expression. 136 | /// 137 | /// - parameter lhs: The affected property. The associated view will have 138 | /// `translatesAutoresizingMaskIntoConstraints` set to `false`. 139 | /// - parameter rhs: The other property. 140 | /// 141 | /// - returns: An `NSLayoutConstraint`. 142 | /// 143 | @discardableResult public func >= (lhs: P, rhs: Expression

) -> NSLayoutConstraint { 144 | return lhs.context.addConstraint(lhs, to: rhs.value, coefficients: rhs.coefficients[0], relation: NSLayoutRelation.greaterThanOrEqual) 145 | } 146 | 147 | // MARK: Addition 148 | 149 | public protocol Addition : Property { } 150 | 151 | public func + (c: CGFloat, rhs: P) -> Expression

{ 152 | return Expression(rhs, [ Coefficients(1, c) ]) 153 | } 154 | 155 | public func + (lhs: P, rhs: CGFloat) -> Expression

{ 156 | return rhs + lhs 157 | } 158 | 159 | public func + (c: CGFloat, rhs: Expression

) -> Expression

{ 160 | return Expression(rhs.value, rhs.coefficients.map { $0 + c }) 161 | } 162 | 163 | public func + (lhs: Expression

, rhs: CGFloat) -> Expression

{ 164 | return rhs + lhs 165 | } 166 | 167 | public func - (c: CGFloat, rhs: P) -> Expression

{ 168 | return Expression(rhs, [ Coefficients(1, -c) ]) 169 | } 170 | 171 | public func - (lhs: P, rhs: CGFloat) -> Expression

{ 172 | return rhs - lhs 173 | } 174 | 175 | public func - (c: CGFloat, rhs: Expression

) -> Expression

{ 176 | return Expression(rhs.value, rhs.coefficients.map { $0 - c}) 177 | } 178 | 179 | public func - (lhs: Expression

, rhs: CGFloat) -> Expression

{ 180 | return rhs - lhs 181 | } 182 | 183 | #if os(iOS) || os(tvOS) 184 | 185 | public func + (lhs: LayoutSupport, c : CGFloat) -> Expression { 186 | return Expression(lhs, [Coefficients(1, c)]) 187 | } 188 | 189 | public func - (lhs: LayoutSupport, c : CGFloat) -> Expression { 190 | return lhs + (-c) 191 | } 192 | 193 | #endif 194 | // MARK: Multiplication 195 | 196 | public protocol Multiplication : Property { } 197 | 198 | public func * (m: CGFloat, rhs: Expression

) -> Expression

{ 199 | return Expression(rhs.value, rhs.coefficients.map { $0 * m }) 200 | } 201 | 202 | public func * (lhs: Expression

, rhs: CGFloat) -> Expression

{ 203 | return rhs * lhs 204 | } 205 | 206 | public func * (m: CGFloat, rhs: P) -> Expression

{ 207 | return Expression(rhs, [ Coefficients(m, 0) ]) 208 | } 209 | 210 | public func * (lhs: P, rhs: CGFloat) -> Expression

{ 211 | return rhs * lhs 212 | } 213 | 214 | public func / (lhs: Expression

, rhs: CGFloat) -> Expression

{ 215 | return lhs * (1 / rhs) 216 | } 217 | 218 | public func / (lhs: P, rhs: CGFloat) -> Expression

{ 219 | return lhs * (1 / rhs) 220 | } 221 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/Size.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Size.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 18/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | public struct Size : Compound, RelativeCompoundEquality, RelativeCompoundInequality { 16 | public let context: Context 17 | public let properties: [Property] 18 | 19 | internal init(_ context: Context, _ properties: [Property]) { 20 | self.context = context 21 | self.properties = properties 22 | } 23 | } 24 | 25 | // MARK: Multiplication 26 | 27 | public func * (m: CGFloat, rhs: Expression) -> Expression { 28 | return Expression(rhs.value, rhs.coefficients.map { $0 * m }) 29 | } 30 | 31 | public func * (lhs: Expression, rhs: CGFloat) -> Expression { 32 | return rhs * lhs 33 | } 34 | 35 | public func * (m: CGFloat, rhs: Size) -> Expression { 36 | return Expression(rhs, [ Coefficients(m, 0), Coefficients(m, 0) ]) 37 | } 38 | 39 | public func * (lhs: Size, rhs: CGFloat) -> Expression { 40 | return rhs * lhs 41 | } 42 | 43 | // MARK: Division 44 | 45 | public func / (lhs: Expression, rhs: CGFloat) -> Expression { 46 | return lhs * (1 / rhs) 47 | } 48 | 49 | public func / (lhs: Size, rhs: CGFloat) -> Expression { 50 | return lhs * (1 / rhs) 51 | } 52 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/View.swift: -------------------------------------------------------------------------------- 1 | // 2 | // View.swift 3 | // Cartography 4 | // 5 | // Created by Robert Böhnke on 26/06/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | import Foundation 10 | 11 | #if os(iOS) || os(tvOS) 12 | import UIKit 13 | public typealias View = UIView 14 | 15 | extension View { 16 | public var car_translatesAutoresizingMaskIntoConstraints: Bool { 17 | get { return translatesAutoresizingMaskIntoConstraints } 18 | set { translatesAutoresizingMaskIntoConstraints = newValue } 19 | } 20 | } 21 | #else 22 | import AppKit 23 | public typealias View = NSView 24 | 25 | extension View { 26 | public var car_translatesAutoresizingMaskIntoConstraints: Bool { 27 | get { return translatesAutoresizingMaskIntoConstraints } 28 | set { translatesAutoresizingMaskIntoConstraints = newValue } 29 | } 30 | } 31 | #endif 32 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/Cartography/ViewUtils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewUtils.swift 3 | // Cartography 4 | // 5 | // Created by Garth Snyder on 11/23/14. 6 | // Copyright (c) 2014 Robert Böhnke. All rights reserved. 7 | // 8 | 9 | #if os(iOS) || os(tvOS) 10 | import UIKit 11 | #else 12 | import AppKit 13 | #endif 14 | 15 | internal func closestCommonAncestor(_ a: View, b: View) -> View? { 16 | let (aSuper, bSuper) = (a.superview, b.superview) 17 | 18 | if a === b { return a } 19 | 20 | if a === bSuper { return a } 21 | 22 | if b === aSuper { return b } 23 | 24 | if aSuper === bSuper { return aSuper } 25 | 26 | let ancestorsOfA = Set(ancestors(a)) 27 | 28 | for ancestor in ancestors(b) { 29 | if ancestorsOfA.contains(ancestor) { 30 | return ancestor 31 | } 32 | } 33 | 34 | return .none 35 | } 36 | 37 | private func ancestors(_ v: View) -> AnySequence { 38 | return AnySequence { () -> AnyIterator in 39 | var view: View? = v 40 | return AnyIterator { 41 | let current = view 42 | view = view?.superview 43 | return current 44 | } 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2014 Robert Böhnke 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 furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | 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 | 21 | This license does not apply to the contents of the images folder. 22 | 23 | --- 24 | 25 | This project uses portions of code from FLKAutoLayout, 26 | copyright (c) 2013 Florian Kugler 27 | 28 | Permission is hereby granted, free of charge, to any person obtaining a copy 29 | of this software and associated documentation files (the "Software"), to deal 30 | in the Software without restriction, including without limitation the rights 31 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 32 | copies of the Software, and to permit persons to whom the Software is furnished 33 | to do so, subject to the following conditions: 34 | 35 | The above copyright notice and this permission notice shall be included in all 36 | copies or substantial portions of the Software. 37 | 38 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 39 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 40 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 41 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 42 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 43 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 44 | THE SOFTWARE. 45 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Cartography/README.md: -------------------------------------------------------------------------------- 1 | # Cartography :iphone::triangular_ruler: 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | Using Cartography, you can set up your Auto Layout constraints in declarative code and without any stringly typing! 12 | 13 | In short, it allows you to replace this: 14 | 15 | 16 | 17 | ```Swift 18 | addConstraint(NSLayoutConstraint( 19 | item: button1, 20 | attribute: .Right, 21 | relatedBy: .Equal, 22 | toItem: button2, 23 | attribute: .Left, 24 | multiplier: 1.0, 25 | constant: -12.0 26 | )) 27 | ``` 28 | 29 | with this 30 | 31 | ```Swift 32 | constrain(button1, button2) { button1, button2 in 33 | button1.right == button2.left - 12 34 | } 35 | ``` 36 | 37 | If you end up using Cartography in production, I'd love to hear from you. You can reach me through [Twitter] or [email]. 38 | 39 | If you need Swift 2.x support, then please use `0.7.0` and below. 40 | 41 | ## Usage 42 | 43 | Call the `constrain` function with your `UIView` or `NSView` instances as well 44 | as a closure in which you declare the constraints between the different 45 | attributes of your views: 46 | 47 | ```swift 48 | constrain(view1, view2) { view1, view2 in 49 | view1.width == (view1.superview!.width - 50) * 0.5 50 | view2.width == view1.width - 50 51 | view1.height == 40 52 | view2.height == view1.height 53 | view1.centerX == view1.superview!.centerX 54 | view2.centerX == view1.centerX 55 | 56 | view1.top >= view1.superview!.top + 20 57 | view2.top == view1.bottom + 20 58 | } 59 | ``` 60 | 61 | 62 | 63 | For every view on the left hand side of an equality or inequality operator, 64 | Cartography will automatically set its 65 | `translatesAutoresizingMaskIntoConstraints` property to `false`. 66 | 67 | If the view is 68 | not controlled by you–for example _if it belongs to a Apple-provided 69 | `UIViewController` class_–you should take appropriate care when declaring its 70 | constraints. 71 | 72 |

73 | 74 | ## Replacing constraints 75 | 76 | You can capture multiple constraints in a group to then replace them with new 77 | constraints at a later point. 78 | 79 | ```swift 80 | constrain(view) { view in 81 | view.width == 100 82 | view.height == 100 83 | } 84 | 85 | let group = ConstraintGroup() 86 | 87 | // Attach `view` to the top left corner of its superview 88 | constrain(view, replace: group) { view in 89 | view.top == view.superview!.top 90 | view.left == view.superview!.left 91 | } 92 | 93 | /* Later */ 94 | 95 | // Move the view to the bottom right corner of its superview 96 | constrain(view, replace: group) { view in 97 | view.bottom == view.superview!.bottom 98 | view.right == view.superview!.right 99 | } 100 | 101 | UIView.animateWithDuration(0.5, animations: view.layoutIfNeeded) 102 | ``` 103 | 104 | For convenience, the `constrain` functions also returns `ConstraintGroup` 105 | instances: 106 | 107 | ```swift 108 | let group = constrain(button) { button in 109 | button.width == 100 110 | button.height == 400 111 | } 112 | ``` 113 | 114 | ## Supported attributes 115 | 116 | 117 | Cartography supports all built-in attributes as of iOS 8 and OS X 10.9, those are: 118 | 119 | 120 | 121 | - `width` 122 | - `height` 123 | - `top` 124 | - `right` 125 | - `bottom` 126 | - `left` 127 | - `leading` 128 | - `trailing` 129 | - `centerX` 130 | - `centerY` 131 | - `baseline` 132 | 133 | as well as the iOS specific 134 | 135 | - `firstBaseline` 136 | - `leftMargin` 137 | - `rightMargin` 138 | - `topMargin` 139 | - `bottomMargin` 140 | - `leadingMargin` 141 | - `trailingMargin` 142 | - `centerXWithinMargins` 143 | - `centerYWithinMargins` 144 | - `edgesWithinMargins` 145 | 146 | These can be further refined using the following operators: `*`, `/`, `+` and 147 | `-`. 148 | 149 | Additionally, it supports convenient compound attributes that allow you to 150 | assign multiple attributes at once: 151 | 152 | ```swift 153 | constrain(view) { view in 154 | view.size == view.superview!.size / 2 155 | view.center == view.superview!.center 156 | } 157 | ``` 158 | 159 | ```swift 160 | constrain(view) { view in 161 | view.edges == inset(view.superview!.edges, 20, 20, 40, 20) 162 | } 163 | ``` 164 | 165 | ### Aligning multiple view 166 | 167 | If you need to align multiple views by a common edge, you can use the `align` 168 | functions: 169 | 170 | ```swift 171 | constrain(view1, view2, view3) { view1, view2, view3 in 172 | align(top: view1, view2, view3) 173 | } 174 | ``` 175 | 176 | Which is equivalent to `view1.top == view2.top; view2.top == view3.top`. Similar 177 | variants exist for `top`, `right` `bottom`, `left`, `leading`, `trailing`, 178 | `centerX`, `centerY` and `baseline`. 179 | 180 | ### Distributing views evenly 181 | 182 | For distributing multiple views, either horizontally or vertically, you can use 183 | the `distribute` functions: 184 | 185 | ```swift 186 | constrain(view1, view2, view3) { view1, view2, view3 in 187 | distribute(by: 10, horizontally: view1, view2, view3) 188 | } 189 | ``` 190 | 191 | Which is equivalent to `view1.trailing == view2.leading - 10; view2.trailing == view3.leading - 10`. 192 | 193 | ## Setting priorities 194 | 195 | You can set the priorities of your constraints using the `~` operator: 196 | 197 | ```swift 198 | constrain(view) { view in 199 | view.width >= 200 ~ 100 200 | view.height >= 200 ~ 100 201 | } 202 | ``` 203 | 204 | ## Capturing constraints 205 | 206 | Since the `==`, `>=`, `<=` and `~` emit `NSLayoutConstraint` instances, you can 207 | capture their results if you need to refer to the layout constraints at a later 208 | time: 209 | 210 | ```swift 211 | var width: NSLayoutConstraint? 212 | 213 | constrain(view) { view in 214 | width = (view.width == 200 ~ 100) 215 | } 216 | ``` 217 | 218 | Note that declaring compound attributes returns multiple constraints at once: 219 | 220 | ```swift 221 | var constraints: [NSLayoutConstraint]? 222 | 223 | constrain(view) { view in 224 | constraints = (view.size == view.superview!.size ~ 100) 225 | } 226 | ``` 227 | 228 | ## Documentation 229 | 230 | Read the documentation [here](http://robb.github.io/Cartography/). For more information, see the [gh-pages](https://github.com/robb/Cartography/tree/gh-pages) branch. 231 | 232 | ## Support 233 | 234 | Please, don't hesitate to [file an 235 | issue](https://github.com/robb/Cartography/issues/new) if you have questions. 236 | 237 | ## About Cartography 238 | 239 | Cartography was built by [Robb Böhnke][me] and was inspired by the excellent 240 | [FLKAutoLayout] by [Florian Kugler][florian]. 241 | 242 | [flkautolayout]: https://github.com/floriankugler/FLKAutoLayout 243 | [florian]: https://github.com/floriankugler 244 | [me]: http://robb.is 245 | [twitter]: https://twitter.com/dlx 246 | [email]: mailto:robb@robb.is 247 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Manifest.lock: -------------------------------------------------------------------------------- 1 | PODS: 2 | - Cartography (1.0.1) 3 | - UIColor+FlatColors (0.0.2) 4 | 5 | DEPENDENCIES: 6 | - Cartography 7 | - UIColor+FlatColors 8 | 9 | SPEC CHECKSUMS: 10 | Cartography: c1460e99395b824d9d75360b0382faeb0b33dcd7 11 | UIColor+FlatColors: 6c699df7a575281794c688c64cee6c44fd1f93b4 12 | 13 | PODFILE CHECKSUM: 8e7c96524d011a1ab9a3ff3f064c099b04f6b392 14 | 15 | COCOAPODS: 1.1.1 16 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Cartography/Cartography-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Cartography : NSObject 3 | @end 4 | @implementation PodsDummy_Cartography 5 | @end 6 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Cartography/Cartography-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Cartography/Cartography-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | 6 | FOUNDATION_EXPORT double CartographyVersionNumber; 7 | FOUNDATION_EXPORT const unsigned char CartographyVersionString[]; 8 | 9 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Cartography/Cartography.modulemap: -------------------------------------------------------------------------------- 1 | framework module Cartography { 2 | umbrella header "Cartography-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Cartography/Cartography.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/Cartography 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 5 | PODS_BUILD_DIR = $BUILD_DIR 6 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 7 | PODS_ROOT = ${SRCROOT} 8 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 9 | SKIP_INSTALL = YES 10 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Cartography/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Cartography 5 | 6 | Copyright (c) 2014 Robert Böhnke 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 furnished 13 | 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 24 | THE SOFTWARE. 25 | 26 | This license does not apply to the contents of the images folder. 27 | 28 | --- 29 | 30 | This project uses portions of code from FLKAutoLayout, 31 | copyright (c) 2013 Florian Kugler 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy 34 | of this software and associated documentation files (the "Software"), to deal 35 | in the Software without restriction, including without limitation the rights 36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 37 | copies of the Software, and to permit persons to whom the Software is furnished 38 | to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in all 41 | copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 49 | THE SOFTWARE. 50 | 51 | 52 | ## UIColor+FlatColors 53 | 54 | The MIT License (MIT) 55 | 56 | Copyright (c) 2014 Giovanni Lodi 57 | 58 | Permission is hereby granted, free of charge, to any person obtaining a copy of 59 | this software and associated documentation files (the "Software"), to deal in 60 | the Software without restriction, including without limitation the rights to 61 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 62 | the Software, and to permit persons to whom the Software is furnished to do so, 63 | subject to the following conditions: 64 | 65 | The above copyright notice and this permission notice shall be included in all 66 | copies or substantial portions of the Software. 67 | 68 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 69 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 70 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 71 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 72 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 73 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 74 | 75 | Generated by CocoaPods - https://cocoapods.org 76 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2014 Robert Böhnke <robb@robb.is> 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is furnished 24 | to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in all 27 | copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | This license does not apply to the contents of the images folder. 38 | 39 | --- 40 | 41 | This project uses portions of code from FLKAutoLayout, 42 | copyright (c) 2013 Florian Kugler <mail@floriankugler.de> 43 | 44 | Permission is hereby granted, free of charge, to any person obtaining a copy 45 | of this software and associated documentation files (the "Software"), to deal 46 | in the Software without restriction, including without limitation the rights 47 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 48 | copies of the Software, and to permit persons to whom the Software is furnished 49 | to do so, subject to the following conditions: 50 | 51 | The above copyright notice and this permission notice shall be included in all 52 | copies or substantial portions of the Software. 53 | 54 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 55 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 56 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 57 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 58 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 59 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 60 | THE SOFTWARE. 61 | 62 | License 63 | MIT 64 | Title 65 | Cartography 66 | Type 67 | PSGroupSpecifier 68 | 69 | 70 | FooterText 71 | The MIT License (MIT) 72 | 73 | Copyright (c) 2014 Giovanni Lodi 74 | 75 | Permission is hereby granted, free of charge, to any person obtaining a copy of 76 | this software and associated documentation files (the "Software"), to deal in 77 | the Software without restriction, including without limitation the rights to 78 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 79 | the Software, and to permit persons to whom the Software is furnished to do so, 80 | subject to the following conditions: 81 | 82 | The above copyright notice and this permission notice shall be included in all 83 | copies or substantial portions of the Software. 84 | 85 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 86 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 87 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 88 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 89 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 90 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 91 | 92 | License 93 | MIT 94 | Title 95 | UIColor+FlatColors 96 | Type 97 | PSGroupSpecifier 98 | 99 | 100 | FooterText 101 | Generated by CocoaPods - https://cocoapods.org 102 | Title 103 | 104 | Type 105 | PSGroupSpecifier 106 | 107 | 108 | StringsTable 109 | Acknowledgements 110 | Title 111 | Acknowledgements 112 | 113 | 114 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ZLSwipeableViewSwiftDemo : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ZLSwipeableViewSwiftDemo 5 | @end 6 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/Cartography/Cartography.framework" 88 | install_framework "$BUILT_PRODUCTS_DIR/UIColor+FlatColors/UIColor_FlatColors.framework" 89 | fi 90 | if [[ "$CONFIGURATION" == "Release" ]]; then 91 | install_framework "$BUILT_PRODUCTS_DIR/Cartography/Cartography.framework" 92 | install_framework "$BUILT_PRODUCTS_DIR/UIColor+FlatColors/UIColor_FlatColors.framework" 93 | fi 94 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | install_resource() 27 | { 28 | if [[ "$1" = /* ]] ; then 29 | RESOURCE_PATH="$1" 30 | else 31 | RESOURCE_PATH="${PODS_ROOT}/$1" 32 | fi 33 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 34 | cat << EOM 35 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 36 | EOM 37 | exit 1 38 | fi 39 | case $RESOURCE_PATH in 40 | *.storyboard) 41 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 42 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 43 | ;; 44 | *.xib) 45 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 46 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 47 | ;; 48 | *.framework) 49 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 50 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 51 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 52 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | ;; 54 | *.xcdatamodel) 55 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 56 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 57 | ;; 58 | *.xcdatamodeld) 59 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 60 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 61 | ;; 62 | *.xcmappingmodel) 63 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 64 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 65 | ;; 66 | *.xcassets) 67 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 68 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 69 | ;; 70 | *) 71 | echo "$RESOURCE_PATH" 72 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 73 | ;; 74 | esac 75 | } 76 | 77 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 78 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 79 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 80 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | fi 83 | rm -f "$RESOURCES_TO_COPY" 84 | 85 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 86 | then 87 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 88 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 89 | while read line; do 90 | if [[ $line != "${PODS_ROOT}*" ]]; then 91 | XCASSET_FILES+=("$line") 92 | fi 93 | done <<<"$OTHER_XCASSETS" 94 | 95 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 96 | fi 97 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | 6 | FOUNDATION_EXPORT double Pods_ZLSwipeableViewSwiftDemoVersionNumber; 7 | FOUNDATION_EXPORT const unsigned char Pods_ZLSwipeableViewSwiftDemoVersionString[]; 8 | 9 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Cartography" "$PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Cartography/Cartography.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors/UIColor_FlatColors.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "Cartography" -framework "UIColor_FlatColors" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ZLSwipeableViewSwiftDemo { 2 | umbrella header "Pods-ZLSwipeableViewSwiftDemo-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemo/Pods-ZLSwipeableViewSwiftDemo.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Cartography" "$PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Cartography/Cartography.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors/UIColor_FlatColors.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "Cartography" -framework "UIColor_FlatColors" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/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 | FMWK 17 | CFBundleShortVersionString 18 | 1.0.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests-acknowledgements.markdown: -------------------------------------------------------------------------------- 1 | # Acknowledgements 2 | This application makes use of the following third party libraries: 3 | 4 | ## Cartography 5 | 6 | Copyright (c) 2014 Robert Böhnke 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 furnished 13 | 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 24 | THE SOFTWARE. 25 | 26 | This license does not apply to the contents of the images folder. 27 | 28 | --- 29 | 30 | This project uses portions of code from FLKAutoLayout, 31 | copyright (c) 2013 Florian Kugler 32 | 33 | Permission is hereby granted, free of charge, to any person obtaining a copy 34 | of this software and associated documentation files (the "Software"), to deal 35 | in the Software without restriction, including without limitation the rights 36 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 37 | copies of the Software, and to permit persons to whom the Software is furnished 38 | to do so, subject to the following conditions: 39 | 40 | The above copyright notice and this permission notice shall be included in all 41 | copies or substantial portions of the Software. 42 | 43 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 44 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 45 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 46 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 47 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 48 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 49 | THE SOFTWARE. 50 | 51 | 52 | ## UIColor+FlatColors 53 | 54 | The MIT License (MIT) 55 | 56 | Copyright (c) 2014 Giovanni Lodi 57 | 58 | Permission is hereby granted, free of charge, to any person obtaining a copy of 59 | this software and associated documentation files (the "Software"), to deal in 60 | the Software without restriction, including without limitation the rights to 61 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 62 | the Software, and to permit persons to whom the Software is furnished to do so, 63 | subject to the following conditions: 64 | 65 | The above copyright notice and this permission notice shall be included in all 66 | copies or substantial portions of the Software. 67 | 68 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 69 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 70 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 71 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 72 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 73 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 74 | 75 | Generated by CocoaPods - https://cocoapods.org 76 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests-acknowledgements.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | PreferenceSpecifiers 6 | 7 | 8 | FooterText 9 | This application makes use of the following third party libraries: 10 | Title 11 | Acknowledgements 12 | Type 13 | PSGroupSpecifier 14 | 15 | 16 | FooterText 17 | Copyright (c) 2014 Robert Böhnke <robb@robb.is> 18 | 19 | Permission is hereby granted, free of charge, to any person obtaining a copy 20 | of this software and associated documentation files (the "Software"), to deal 21 | in the Software without restriction, including without limitation the rights 22 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 23 | copies of the Software, and to permit persons to whom the Software is furnished 24 | to do so, subject to the following conditions: 25 | 26 | The above copyright notice and this permission notice shall be included in all 27 | copies or substantial portions of the Software. 28 | 29 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 30 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 31 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 32 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 33 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 34 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 35 | THE SOFTWARE. 36 | 37 | This license does not apply to the contents of the images folder. 38 | 39 | --- 40 | 41 | This project uses portions of code from FLKAutoLayout, 42 | copyright (c) 2013 Florian Kugler <mail@floriankugler.de> 43 | 44 | Permission is hereby granted, free of charge, to any person obtaining a copy 45 | of this software and associated documentation files (the "Software"), to deal 46 | in the Software without restriction, including without limitation the rights 47 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 48 | copies of the Software, and to permit persons to whom the Software is furnished 49 | to do so, subject to the following conditions: 50 | 51 | The above copyright notice and this permission notice shall be included in all 52 | copies or substantial portions of the Software. 53 | 54 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 55 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 56 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 57 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 58 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 59 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 60 | THE SOFTWARE. 61 | 62 | License 63 | MIT 64 | Title 65 | Cartography 66 | Type 67 | PSGroupSpecifier 68 | 69 | 70 | FooterText 71 | The MIT License (MIT) 72 | 73 | Copyright (c) 2014 Giovanni Lodi 74 | 75 | Permission is hereby granted, free of charge, to any person obtaining a copy of 76 | this software and associated documentation files (the "Software"), to deal in 77 | the Software without restriction, including without limitation the rights to 78 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 79 | the Software, and to permit persons to whom the Software is furnished to do so, 80 | subject to the following conditions: 81 | 82 | The above copyright notice and this permission notice shall be included in all 83 | copies or substantial portions of the Software. 84 | 85 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 86 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 87 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 88 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 89 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 90 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 91 | 92 | License 93 | MIT 94 | Title 95 | UIColor+FlatColors 96 | Type 97 | PSGroupSpecifier 98 | 99 | 100 | FooterText 101 | Generated by CocoaPods - https://cocoapods.org 102 | Title 103 | 104 | Type 105 | PSGroupSpecifier 106 | 107 | 108 | StringsTable 109 | Acknowledgements 110 | Title 111 | Acknowledgements 112 | 113 | 114 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_Pods_ZLSwipeableViewSwiftDemoTests : NSObject 3 | @end 4 | @implementation PodsDummy_Pods_ZLSwipeableViewSwiftDemoTests 5 | @end 6 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests-frameworks.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | echo "mkdir -p ${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 5 | mkdir -p "${CONFIGURATION_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 6 | 7 | SWIFT_STDLIB_PATH="${DT_TOOLCHAIN_DIR}/usr/lib/swift/${PLATFORM_NAME}" 8 | 9 | install_framework() 10 | { 11 | if [ -r "${BUILT_PRODUCTS_DIR}/$1" ]; then 12 | local source="${BUILT_PRODUCTS_DIR}/$1" 13 | elif [ -r "${BUILT_PRODUCTS_DIR}/$(basename "$1")" ]; then 14 | local source="${BUILT_PRODUCTS_DIR}/$(basename "$1")" 15 | elif [ -r "$1" ]; then 16 | local source="$1" 17 | fi 18 | 19 | local destination="${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 20 | 21 | if [ -L "${source}" ]; then 22 | echo "Symlinked..." 23 | source="$(readlink "${source}")" 24 | fi 25 | 26 | # use filter instead of exclude so missing patterns dont' throw errors 27 | echo "rsync -av --filter \"- CVS/\" --filter \"- .svn/\" --filter \"- .git/\" --filter \"- .hg/\" --filter \"- Headers\" --filter \"- PrivateHeaders\" --filter \"- Modules\" \"${source}\" \"${destination}\"" 28 | rsync -av --filter "- CVS/" --filter "- .svn/" --filter "- .git/" --filter "- .hg/" --filter "- Headers" --filter "- PrivateHeaders" --filter "- Modules" "${source}" "${destination}" 29 | 30 | local basename 31 | basename="$(basename -s .framework "$1")" 32 | binary="${destination}/${basename}.framework/${basename}" 33 | if ! [ -r "$binary" ]; then 34 | binary="${destination}/${basename}" 35 | fi 36 | 37 | # Strip invalid architectures so "fat" simulator / device frameworks work on device 38 | if [[ "$(file "$binary")" == *"dynamically linked shared library"* ]]; then 39 | strip_invalid_archs "$binary" 40 | fi 41 | 42 | # Resign the code if required by the build settings to avoid unstable apps 43 | code_sign_if_enabled "${destination}/$(basename "$1")" 44 | 45 | # Embed linked Swift runtime libraries. No longer necessary as of Xcode 7. 46 | if [ "${XCODE_VERSION_MAJOR}" -lt 7 ]; then 47 | local swift_runtime_libs 48 | swift_runtime_libs=$(xcrun otool -LX "$binary" | grep --color=never @rpath/libswift | sed -E s/@rpath\\/\(.+dylib\).*/\\1/g | uniq -u && exit ${PIPESTATUS[0]}) 49 | for lib in $swift_runtime_libs; do 50 | echo "rsync -auv \"${SWIFT_STDLIB_PATH}/${lib}\" \"${destination}\"" 51 | rsync -auv "${SWIFT_STDLIB_PATH}/${lib}" "${destination}" 52 | code_sign_if_enabled "${destination}/${lib}" 53 | done 54 | fi 55 | } 56 | 57 | # Signs a framework with the provided identity 58 | code_sign_if_enabled() { 59 | if [ -n "${EXPANDED_CODE_SIGN_IDENTITY}" -a "${CODE_SIGNING_REQUIRED}" != "NO" -a "${CODE_SIGNING_ALLOWED}" != "NO" ]; then 60 | # Use the current code_sign_identitiy 61 | echo "Code Signing $1 with Identity ${EXPANDED_CODE_SIGN_IDENTITY_NAME}" 62 | echo "/usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements \"$1\"" 63 | /usr/bin/codesign --force --sign ${EXPANDED_CODE_SIGN_IDENTITY} ${OTHER_CODE_SIGN_FLAGS} --preserve-metadata=identifier,entitlements "$1" 64 | fi 65 | } 66 | 67 | # Strip invalid architectures 68 | strip_invalid_archs() { 69 | binary="$1" 70 | # Get architectures for current file 71 | archs="$(lipo -info "$binary" | rev | cut -d ':' -f1 | rev)" 72 | stripped="" 73 | for arch in $archs; do 74 | if ! [[ "${VALID_ARCHS}" == *"$arch"* ]]; then 75 | # Strip non-valid architectures in-place 76 | lipo -remove "$arch" -output "$binary" "$binary" || exit 1 77 | stripped="$stripped $arch" 78 | fi 79 | done 80 | if [[ "$stripped" ]]; then 81 | echo "Stripped $binary of architectures:$stripped" 82 | fi 83 | } 84 | 85 | 86 | if [[ "$CONFIGURATION" == "Debug" ]]; then 87 | install_framework "$BUILT_PRODUCTS_DIR/Cartography/Cartography.framework" 88 | install_framework "$BUILT_PRODUCTS_DIR/UIColor+FlatColors/UIColor_FlatColors.framework" 89 | fi 90 | if [[ "$CONFIGURATION" == "Release" ]]; then 91 | install_framework "$BUILT_PRODUCTS_DIR/Cartography/Cartography.framework" 92 | install_framework "$BUILT_PRODUCTS_DIR/UIColor+FlatColors/UIColor_FlatColors.framework" 93 | fi 94 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests-resources.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 5 | 6 | RESOURCES_TO_COPY=${PODS_ROOT}/resources-to-copy-${TARGETNAME}.txt 7 | > "$RESOURCES_TO_COPY" 8 | 9 | XCASSET_FILES=() 10 | 11 | case "${TARGETED_DEVICE_FAMILY}" in 12 | 1,2) 13 | TARGET_DEVICE_ARGS="--target-device ipad --target-device iphone" 14 | ;; 15 | 1) 16 | TARGET_DEVICE_ARGS="--target-device iphone" 17 | ;; 18 | 2) 19 | TARGET_DEVICE_ARGS="--target-device ipad" 20 | ;; 21 | *) 22 | TARGET_DEVICE_ARGS="--target-device mac" 23 | ;; 24 | esac 25 | 26 | install_resource() 27 | { 28 | if [[ "$1" = /* ]] ; then 29 | RESOURCE_PATH="$1" 30 | else 31 | RESOURCE_PATH="${PODS_ROOT}/$1" 32 | fi 33 | if [[ ! -e "$RESOURCE_PATH" ]] ; then 34 | cat << EOM 35 | error: Resource "$RESOURCE_PATH" not found. Run 'pod install' to update the copy resources script. 36 | EOM 37 | exit 1 38 | fi 39 | case $RESOURCE_PATH in 40 | *.storyboard) 41 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 42 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .storyboard`.storyboardc" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 43 | ;; 44 | *.xib) 45 | echo "ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile ${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib $RESOURCE_PATH --sdk ${SDKROOT} ${TARGET_DEVICE_ARGS}" 46 | ibtool --reference-external-strings-file --errors --warnings --notices --minimum-deployment-target ${!DEPLOYMENT_TARGET_SETTING_NAME} --output-format human-readable-text --compile "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename \"$RESOURCE_PATH\" .xib`.nib" "$RESOURCE_PATH" --sdk "${SDKROOT}" ${TARGET_DEVICE_ARGS} 47 | ;; 48 | *.framework) 49 | echo "mkdir -p ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 50 | mkdir -p "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 51 | echo "rsync -av $RESOURCE_PATH ${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 52 | rsync -av "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}" 53 | ;; 54 | *.xcdatamodel) 55 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH"`.mom\"" 56 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodel`.mom" 57 | ;; 58 | *.xcdatamodeld) 59 | echo "xcrun momc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd\"" 60 | xcrun momc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcdatamodeld`.momd" 61 | ;; 62 | *.xcmappingmodel) 63 | echo "xcrun mapc \"$RESOURCE_PATH\" \"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm\"" 64 | xcrun mapc "$RESOURCE_PATH" "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/`basename "$RESOURCE_PATH" .xcmappingmodel`.cdm" 65 | ;; 66 | *.xcassets) 67 | ABSOLUTE_XCASSET_FILE="$RESOURCE_PATH" 68 | XCASSET_FILES+=("$ABSOLUTE_XCASSET_FILE") 69 | ;; 70 | *) 71 | echo "$RESOURCE_PATH" 72 | echo "$RESOURCE_PATH" >> "$RESOURCES_TO_COPY" 73 | ;; 74 | esac 75 | } 76 | 77 | mkdir -p "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 78 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 79 | if [[ "${ACTION}" == "install" ]] && [[ "${SKIP_INSTALL}" == "NO" ]]; then 80 | mkdir -p "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 81 | rsync -avr --copy-links --no-relative --exclude '*/.svn/*' --files-from="$RESOURCES_TO_COPY" / "${INSTALL_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 82 | fi 83 | rm -f "$RESOURCES_TO_COPY" 84 | 85 | if [[ -n "${WRAPPER_EXTENSION}" ]] && [ "`xcrun --find actool`" ] && [ -n "$XCASSET_FILES" ] 86 | then 87 | # Find all other xcassets (this unfortunately includes those of path pods and other targets). 88 | OTHER_XCASSETS=$(find "$PWD" -iname "*.xcassets" -type d) 89 | while read line; do 90 | if [[ $line != "${PODS_ROOT}*" ]]; then 91 | XCASSET_FILES+=("$line") 92 | fi 93 | done <<<"$OTHER_XCASSETS" 94 | 95 | printf "%s\0" "${XCASSET_FILES[@]}" | xargs -0 xcrun actool --output-format human-readable-text --notices --warnings --platform "${PLATFORM_NAME}" --minimum-deployment-target "${!DEPLOYMENT_TARGET_SETTING_NAME}" ${TARGET_DEVICE_ARGS} --compress-pngs --compile "${BUILT_PRODUCTS_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}" 96 | fi 97 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | 6 | FOUNDATION_EXPORT double Pods_ZLSwipeableViewSwiftDemoTestsVersionNumber; 7 | FOUNDATION_EXPORT const unsigned char Pods_ZLSwipeableViewSwiftDemoTestsVersionString[]; 8 | 9 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests.debug.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Cartography" "$PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Cartography/Cartography.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors/UIColor_FlatColors.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "Cartography" -framework "UIColor_FlatColors" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests.modulemap: -------------------------------------------------------------------------------- 1 | framework module Pods_ZLSwipeableViewSwiftDemoTests { 2 | umbrella header "Pods-ZLSwipeableViewSwiftDemoTests-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/Pods-ZLSwipeableViewSwiftDemoTests/Pods-ZLSwipeableViewSwiftDemoTests.release.xcconfig: -------------------------------------------------------------------------------- 1 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES 2 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES 3 | FRAMEWORK_SEARCH_PATHS = $(inherited) "$PODS_CONFIGURATION_BUILD_DIR/Cartography" "$PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors" 4 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 5 | LD_RUNPATH_SEARCH_PATHS = $(inherited) '@executable_path/Frameworks' '@loader_path/Frameworks' 6 | OTHER_CFLAGS = $(inherited) -iquote "$PODS_CONFIGURATION_BUILD_DIR/Cartography/Cartography.framework/Headers" -iquote "$PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors/UIColor_FlatColors.framework/Headers" 7 | OTHER_LDFLAGS = $(inherited) -framework "Cartography" -framework "UIColor_FlatColors" 8 | OTHER_SWIFT_FLAGS = $(inherited) "-D" "COCOAPODS" 9 | PODS_BUILD_DIR = $BUILD_DIR 10 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 11 | PODS_ROOT = ${SRCROOT}/Pods 12 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/UIColor+FlatColors/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 | FMWK 17 | CFBundleShortVersionString 18 | 0.0.2 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | ${CURRENT_PROJECT_VERSION} 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/UIColor+FlatColors/UIColor+FlatColors-dummy.m: -------------------------------------------------------------------------------- 1 | #import 2 | @interface PodsDummy_UIColor_FlatColors : NSObject 3 | @end 4 | @implementation PodsDummy_UIColor_FlatColors 5 | @end 6 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/UIColor+FlatColors/UIColor+FlatColors-prefix.pch: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/UIColor+FlatColors/UIColor+FlatColors-umbrella.h: -------------------------------------------------------------------------------- 1 | #ifdef __OBJC__ 2 | #import 3 | #endif 4 | 5 | #import "UIColor+FlatColors.h" 6 | 7 | FOUNDATION_EXPORT double UIColor_FlatColorsVersionNumber; 8 | FOUNDATION_EXPORT const unsigned char UIColor_FlatColorsVersionString[]; 9 | 10 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/UIColor+FlatColors/UIColor+FlatColors.modulemap: -------------------------------------------------------------------------------- 1 | framework module UIColor_FlatColors { 2 | umbrella header "UIColor+FlatColors-umbrella.h" 3 | 4 | export * 5 | module * { export * } 6 | } 7 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/Target Support Files/UIColor+FlatColors/UIColor+FlatColors.xcconfig: -------------------------------------------------------------------------------- 1 | CONFIGURATION_BUILD_DIR = $PODS_CONFIGURATION_BUILD_DIR/UIColor+FlatColors 2 | GCC_PREPROCESSOR_DEFINITIONS = $(inherited) COCOAPODS=1 3 | HEADER_SEARCH_PATHS = "${PODS_ROOT}/Headers/Private" "${PODS_ROOT}/Headers/Public" 4 | PODS_BUILD_DIR = $BUILD_DIR 5 | PODS_CONFIGURATION_BUILD_DIR = $PODS_BUILD_DIR/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME) 6 | PODS_ROOT = ${SRCROOT} 7 | PRODUCT_BUNDLE_IDENTIFIER = org.cocoapods.${PRODUCT_NAME:rfc1034identifier} 8 | SKIP_INSTALL = YES 9 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/UIColor+FlatColors/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Giovanni Lodi 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/UIColor+FlatColors/README.md: -------------------------------------------------------------------------------- 1 | UIColor+FlatColors 2 | ================== 3 | 4 | `UIColor+FlatColors` is a category that extends `UIColor` with methods to get the colors from the [Flat UI](http://designmodo.github.io/Flat-UI/) framework by [designmodo](http://designmodo.com/). 5 | 6 | That's it. 7 | 8 | 9 | 10 | I suggest you take a look at [FlatUIKit](https://github.com/Grouper/FlatUIKit) if you are looking for the full components of the Flat UI framework to use in your app. 11 | 12 | ## Installation with CocoaPods 13 | 14 | ```ruby 15 | platform :ios 16 | 17 | pod 'UIColor+FlatColors' 18 | ``` 19 | 20 | ## Usage 21 | 22 | Get the colors from a `UIColor` class method following this naming pattern: `flat<# color_name #>Color`. To see all the available colors check [flatuicolors.com](http://flatuicolors.com/). 23 | 24 | ```objc 25 | someViewYouWantToColor.backgroundColor = [UIColor flatEmeraldColor]; 26 | ``` 27 | 28 | ## License 29 | 30 | `UIColor+FlatColors` is released under the [MIT license](https://github.com/mokagio/UIColor-FlatColors/blob/master/LICENSE). 31 | 32 | --- 33 | 34 | Hacked together with passion by [@mokagio](https://twitter.com/mokagio) 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/UIColor+FlatColors/UIColor+FlatColors/UIColor+FlatColors.h: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2014 Giovanni Lodi 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files (the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #import 23 | 24 | @interface UIColor (FlatColors) 25 | 26 | + (UIColor *)flatTurquoiseColor; 27 | 28 | + (UIColor *)flatGreenSeaColor; 29 | 30 | + (UIColor *)flatEmeraldColor; 31 | 32 | + (UIColor *)flatNephritisColor; 33 | 34 | + (UIColor *)flatPeterRiverColor; 35 | 36 | + (UIColor *)flatBelizeHoleColor; 37 | 38 | + (UIColor *)flatAmethystColor; 39 | 40 | + (UIColor *)flatWisteriaColor; 41 | 42 | + (UIColor *)flatWetAsphaltColor; 43 | 44 | + (UIColor *)flatMidnightBlueColor; 45 | 46 | + (UIColor *)flatSunFlowerColor; 47 | 48 | + (UIColor *)flatOrangeColor; 49 | 50 | + (UIColor *)flatCarrotColor; 51 | 52 | + (UIColor *)flatPumpkinColor; 53 | 54 | + (UIColor *)flatAlizarinColor; 55 | 56 | + (UIColor *)flatPomegranateColor; 57 | 58 | + (UIColor *)flatCloudsColor; 59 | 60 | + (UIColor *)flatSilverColor; 61 | 62 | + (UIColor *)flatConcreteColor; 63 | 64 | + (UIColor *)flatAsbestosColor; 65 | 66 | @end 67 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/Pods/UIColor+FlatColors/UIColor+FlatColors/UIColor+FlatColors.m: -------------------------------------------------------------------------------- 1 | // The MIT License (MIT) 2 | // 3 | // Copyright (c) 2014 Giovanni Lodi 4 | // 5 | // Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | // this software and associated documentation files (the "Software"), to deal in 7 | // the Software without restriction, including without limitation the rights to 8 | // use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | // the Software, and to permit persons to whom the Software is furnished to do so, 10 | // subject to the following conditions: 11 | // 12 | // The above copyright notice and this permission notice shall be included in all 13 | // copies or substantial portions of the Software. 14 | // 15 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | // FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | // COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | // IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | // CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | 22 | #import "UIColor+FlatColors.h" 23 | 24 | @implementation UIColor (FlatColors) 25 | 26 | // See http://blog.alexedge.co.uk/speeding-up-uicolor-categories/ 27 | #define AGEColorImplement(COLOR_NAME,RED,GREEN,BLUE) \ 28 | + (UIColor *)COLOR_NAME{ \ 29 | static UIColor* COLOR_NAME##_color; \ 30 | static dispatch_once_t COLOR_NAME##_onceToken; \ 31 | dispatch_once(&COLOR_NAME##_onceToken, ^{ \ 32 | COLOR_NAME##_color = [UIColor colorWithRed:RED green:GREEN blue:BLUE alpha:1.0]; \ 33 | }); \ 34 | return COLOR_NAME##_color; \ 35 | } 36 | 37 | AGEColorImplement(flatTurquoiseColor, 0.10196078431372549, 0.7372549019607844, 0.611764705882353) 38 | AGEColorImplement(flatGreenSeaColor, 0.08627450980392157, 0.6274509803921569, 0.5215686274509804) 39 | AGEColorImplement(flatEmeraldColor, 0.1803921568627451, 0.8, 0.44313725490196076) 40 | AGEColorImplement(flatNephritisColor, 0.15294117647058825, 0.6823529411764706, 0.3764705882352941) 41 | AGEColorImplement(flatPeterRiverColor, 0.20392156862745098, 0.596078431372549, 0.8588235294117647) 42 | AGEColorImplement(flatBelizeHoleColor, 0.1607843137254902, 0.5019607843137255, 0.7254901960784313) 43 | AGEColorImplement(flatAmethystColor, 0.6078431372549019, 0.34901960784313724, 0.7137254901960784) 44 | AGEColorImplement(flatWisteriaColor, 0.5568627450980392, 0.26666666666666666, 0.6784313725490196) 45 | AGEColorImplement(flatWetAsphaltColor, 0.20392156862745098, 0.28627450980392155, 0.3686274509803922) 46 | AGEColorImplement(flatMidnightBlueColor, 0.17254901960784313, 0.24313725490196078, 0.3137254901960784) 47 | AGEColorImplement(flatSunFlowerColor, 0.9450980392156862, 0.7686274509803922, 0.058823529411764705) 48 | AGEColorImplement(flatOrangeColor, 0.9529411764705882, 0.611764705882353, 0.07058823529411765) 49 | AGEColorImplement(flatCarrotColor, 0.9019607843137255, 0.49411764705882355, 0.13333333333333333) 50 | AGEColorImplement(flatPumpkinColor, 0.8274509803921568, 0.32941176470588235, 0) 51 | AGEColorImplement(flatAlizarinColor, 0.9058823529411765, 0.2980392156862745, 0.23529411764705882) 52 | AGEColorImplement(flatPomegranateColor, 0.7529411764705882, 0.2235294117647059, 0.16862745098039217) 53 | AGEColorImplement(flatCloudsColor, 0.9254901960784314, 0.9411764705882353, 0.9450980392156862) 54 | AGEColorImplement(flatSilverColor, 0.7411764705882353, 0.7647058823529411, 0.7803921568627451) 55 | AGEColorImplement(flatConcreteColor, 0.5843137254901961, 0.6470588235294118, 0.6509803921568628) 56 | AGEColorImplement(flatAsbestosColor, 0.4980392156862745, 0.5490196078431373, 0.5529411764705883) 57 | 58 | @end -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/AlwaysSwipeDemoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AlwaysSwipeViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 10/23/15. 6 | // Copyright © 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class AlwaysSwipeDemoViewController: ZLSwipeableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | swipeableView.shouldSwipeView = { _, _, _ in true } 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 4/27/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | class AppDelegate: UIResponder, UIApplicationDelegate { 13 | 14 | var window: UIWindow? 15 | 16 | 17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 18 | window = UIWindow(frame: UIScreen.main.bounds) 19 | if let window = window { 20 | let menuViewController = MenuTableViewController(style: .grouped) 21 | window.rootViewController = UINavigationController(rootViewController: menuViewController) 22 | window.makeKeyAndVisible() 23 | } 24 | return true 25 | } 26 | 27 | func applicationWillResignActive(_ application: UIApplication) { 28 | // 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. 29 | // 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. 30 | } 31 | 32 | func applicationDidEnterBackground(_ application: UIApplication) { 33 | // 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. 34 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 35 | } 36 | 37 | func applicationWillEnterForeground(_ application: UIApplication) { 38 | // 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. 39 | } 40 | 41 | func applicationDidBecomeActive(_ application: UIApplication) { 42 | // 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. 43 | } 44 | 45 | func applicationWillTerminate(_ application: UIApplication) { 46 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 47 | } 48 | 49 | 50 | } 51 | 52 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/CardContentView.xib: -------------------------------------------------------------------------------- 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 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/CardView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CardView.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 5/24/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CardView: UIView { 12 | 13 | override init(frame: CGRect) { 14 | super.init(frame: frame) 15 | setup() 16 | } 17 | 18 | required init?(coder aDecoder: NSCoder) { 19 | super.init(coder: aDecoder) 20 | setup() 21 | } 22 | 23 | func setup() { 24 | // Shadow 25 | layer.shadowColor = UIColor.black.cgColor 26 | layer.shadowOpacity = 0.25 27 | layer.shadowOffset = CGSize(width: 0, height: 1.5) 28 | layer.shadowRadius = 4.0 29 | layer.shouldRasterize = true 30 | layer.rasterizationScale = UIScreen.main.scale 31 | 32 | // Corner Radius 33 | layer.cornerRadius = 10.0; 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/CustomAnimationDemoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomAnimationDemoViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 5/25/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CustomAnimationDemoViewController: ZLSwipeableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | func toRadian(_ degree: CGFloat) -> CGFloat { 16 | return degree * CGFloat(Double.pi/180) 17 | } 18 | func rotateAndTranslateView(_ view: UIView, forDegree degree: CGFloat, translation: CGPoint, duration: TimeInterval, offsetFromCenter offset: CGPoint, swipeableView: ZLSwipeableView) { 19 | UIView.animate(withDuration: duration, delay: 0, options: .allowUserInteraction, animations: { 20 | view.center = swipeableView.convert(swipeableView.center, from: swipeableView.superview) 21 | var transform = CGAffineTransform(translationX: offset.x, y: offset.y) 22 | transform = transform.rotated(by: toRadian(degree)) 23 | transform = transform.translatedBy(x: -offset.x, y: -offset.y) 24 | transform = transform.translatedBy(x: translation.x, y: translation.y) 25 | view.transform = transform 26 | }, completion: nil) 27 | } 28 | swipeableView.numberOfActiveView = 10 29 | swipeableView.animateView = {(view: UIView, index: Int, views: [UIView], swipeableView: ZLSwipeableView) in 30 | let degree = CGFloat(sin(0.5*Double(index))) 31 | let offset = CGPoint(x: 0, y: swipeableView.bounds.height*0.3) 32 | let translation = CGPoint(x: degree*10, y: CGFloat(-index*5)) 33 | let duration = 0.4 34 | rotateAndTranslateView(view, forDegree: degree, translation: translation, duration: duration, offsetFromCenter: offset, swipeableView: swipeableView) 35 | } 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/CustomDirectionDemoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomDirectionDemoViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 5/25/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CustomDirectionDemoViewController: ZLSwipeableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | let segmentControl = UISegmentedControl(items: [" ", "←", "↑", "→", "↓", "↔︎", "↕︎", "☩"]) 17 | segmentControl.selectedSegmentIndex = 5 18 | navigationItem.titleView = segmentControl 19 | 20 | segmentControl.addTarget(self, action: #selector(segmentedControlFired), for: .valueChanged) 21 | } 22 | 23 | // MARK: - Actions 24 | 25 | @objc func segmentedControlFired(control: AnyObject?) { 26 | if let control = control as? UISegmentedControl { 27 | let directions: [ZLSwipeableViewDirection] = [.None, .Left, .Up, .Right, .Down, .Horizontal, .Vertical, .All] 28 | self.swipeableView.allowedDirection = directions[control.selectedSegmentIndex] 29 | } 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/CustomSwipeDemoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CustomSwipeDemoViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 5/25/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CustomSwipeDemoViewController: ZLSwipeableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | leftBarButtonItem.action = #selector(leftBarButtonAction) 17 | upBarButtonItem.action = #selector(upBarButtonAction) 18 | 19 | // change how ZLSwipeableViewDirection gets interpreted to location and direction 20 | swipeableView.interpretDirection = {(topView: UIView, direction: ZLSwipeableViewDirection, views: [UIView], swipeableView: ZLSwipeableView) in 21 | let programmaticSwipeVelocity = CGFloat(500) 22 | let location = CGPoint(x: topView.center.x-30, y: topView.center.y*0.1) 23 | var directionVector: CGVector? 24 | switch direction { 25 | case ZLSwipeableViewDirection.Left: 26 | directionVector = CGVector(dx: -programmaticSwipeVelocity, dy: 0) 27 | case ZLSwipeableViewDirection.Right: 28 | directionVector = CGVector(dx: programmaticSwipeVelocity, dy: 0) 29 | case ZLSwipeableViewDirection.Up: 30 | directionVector = CGVector(dx: 0, dy: -programmaticSwipeVelocity) 31 | case ZLSwipeableViewDirection.Down: 32 | directionVector = CGVector(dx: 0, dy: programmaticSwipeVelocity) 33 | default: 34 | directionVector = CGVector(dx: 0, dy: 0) 35 | } 36 | return (location, directionVector!) 37 | } 38 | 39 | } 40 | 41 | // MARK: - Actions 42 | 43 | @objc func leftBarButtonAction() { 44 | self.swipeableView.swipeTopView(fromPoint: CGPoint(x: 10, y: 300), inDirection: CGVector(dx: -700, dy: -300)) 45 | } 46 | 47 | @objc func upBarButtonAction() { 48 | self.swipeableView.swipeTopView(fromPoint: CGPoint(x: 100, y: 30), inDirection: CGVector(dx: 100, dy: -800)) 49 | } 50 | 51 | } 52 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/HistoryDemoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UndoDemoViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 5/25/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class HistoryDemoViewController: ZLSwipeableViewController { 12 | 13 | override func viewDidLoad() { 14 | super.viewDidLoad() 15 | 16 | swipeableView.numberOfHistoryItem = UInt.max 17 | swipeableView.allowedDirection = Direction.All 18 | 19 | let rightBarButtonItemTitle = "Rewind" 20 | 21 | func updateRightBarButtonItem() { 22 | let historyLength = self.swipeableView.history.count 23 | let enabled = historyLength != 0 24 | self.navigationItem.rightBarButtonItem?.isEnabled = enabled 25 | if !enabled { 26 | self.navigationItem.rightBarButtonItem?.title = rightBarButtonItemTitle 27 | return 28 | } 29 | let suffix = " (\(historyLength))" 30 | self.navigationItem.rightBarButtonItem?.title = "\(rightBarButtonItemTitle)\(suffix)" 31 | } 32 | 33 | swipeableView.didSwipe = {view, direction, vector in 34 | print("Did swipe view in direction: \(direction)") 35 | updateRightBarButtonItem() 36 | } 37 | 38 | // ↺ 39 | let rightButton = UIBarButtonItem(title: rightBarButtonItemTitle, style: .plain, target: self, action: #selector(rightButtonClicked)) 40 | navigationItem.rightBarButtonItem = rightButton 41 | 42 | updateRightBarButtonItem() 43 | } 44 | 45 | // MARK: - Actions 46 | 47 | @objc func rightButtonClicked() { 48 | self.swipeableView.rewind() 49 | // updateRightBarButtonItem() 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/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 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/MenuTableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MenuTableViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 5/25/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class MenuTableViewController: UITableViewController { 12 | 13 | let demoViewControllers = [("Default", ZLSwipeableViewController.self), 14 | ("Custom Animation", CustomAnimationDemoViewController.self), 15 | ("Custom Swipe", CustomSwipeDemoViewController.self), 16 | ("Allowed Direction", CustomDirectionDemoViewController.self), 17 | ("History", HistoryDemoViewController.self), 18 | ("Previous View", PreviousViewDemoViewController.self), 19 | ("Should Swipe", ShouldSwipeDemoViewController.self), 20 | ("Always Swipe", AlwaysSwipeDemoViewController.self)] 21 | 22 | override func viewDidLoad() { 23 | super.viewDidLoad() 24 | 25 | title = "ZLSwipeableView" 26 | } 27 | 28 | // MARK: - Table view data source 29 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 30 | return demoViewControllers.count 31 | } 32 | 33 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 34 | let cellIdentifier = String(format: "s%li-r%li", indexPath.section, indexPath.row) 35 | var cell: UITableViewCell! = tableView.dequeueReusableCell(withIdentifier: cellIdentifier) 36 | if cell == nil { 37 | cell = UITableViewCell(style: .default, reuseIdentifier: cellIdentifier) 38 | } 39 | 40 | cell.textLabel?.text = titleForRowAtIndexPath(indexPath) 41 | cell.accessoryType = .disclosureIndicator 42 | return cell 43 | } 44 | 45 | override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { 46 | tableView.deselectRow(at: indexPath, animated: true) 47 | 48 | let title = titleForRowAtIndexPath(indexPath) 49 | let vc = viewControllerForRowAtIndexPath(indexPath) 50 | vc.title = title 51 | navigationController?.pushViewController(vc, animated: true) 52 | } 53 | 54 | func titleForRowAtIndexPath(_ indexPath: IndexPath) -> String { 55 | let (title, _) = demoViewControllers[indexPath.row] 56 | return title 57 | } 58 | 59 | func viewControllerForRowAtIndexPath(_ indexPath: IndexPath) -> ZLSwipeableViewController { 60 | let (_, vc) = demoViewControllers[indexPath.row] 61 | return vc.init() 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/PreviousViewDemoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PreviousViewDemoViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 10/23/15. 6 | // Copyright © 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public func +(lhs: CGPoint, rhs: CGPoint) -> CGPoint { 12 | return CGPoint(x: lhs.x + rhs.x, y: lhs.y + rhs.y) 13 | } 14 | 15 | class PreviousViewDemoViewController: ZLSwipeableViewController { 16 | 17 | override func viewDidLoad() { 18 | super.viewDidLoad() 19 | 20 | swipeableView.numberOfHistoryItem = UInt.max 21 | swipeableView.allowedDirection = Direction.All 22 | 23 | let rightBarButtonItemTitle = "Load Previous" 24 | 25 | swipeableView.previousView = { 26 | if let view = self.nextCardView() { 27 | self.applyRandomTansform(view) 28 | return view 29 | } 30 | return nil 31 | } 32 | 33 | // ↺ 34 | let rightBarButtonItem = UIBarButtonItem(title: rightBarButtonItemTitle, style: .plain, target: self, action: #selector(rightBarButtonClicked)) 35 | navigationItem.rightBarButtonItem = rightBarButtonItem 36 | 37 | // Load previous by tap the card 38 | // swipeableView.didTap = {view, location in 39 | // self.swipeableView.rewind() 40 | // } 41 | } 42 | 43 | func applyRandomTansform(_ view: UIView) { 44 | let width = swipeableView.bounds.width 45 | let height = swipeableView.bounds.height 46 | let distance = max(width, height) 47 | 48 | func randomRadian() -> CGFloat { 49 | return CGFloat(arc4random() % 360) * CGFloat(Double.pi / 180) 50 | } 51 | 52 | var transform = CGAffineTransform(rotationAngle: randomRadian()) 53 | transform = transform.translatedBy(x: distance, y: 0) 54 | transform = transform.rotated(by: randomRadian()) 55 | view.transform = transform 56 | } 57 | 58 | // MARK: - Actions 59 | 60 | @objc func rightBarButtonClicked() { 61 | self.swipeableView.rewind() 62 | } 63 | 64 | } 65 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/ShouldSwipeDemoViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ShouldSwipeDemoViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 6/17/15. 6 | // Copyright © 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ShouldSwipeDemoViewController: ZLSwipeableViewController { 12 | 13 | var shouldSwipe = true 14 | override func viewDidLoad() { 15 | super.viewDidLoad() 16 | 17 | self.title = "Should Swipe 👍" 18 | 19 | Timer.scheduledTimer(timeInterval: 3, target: self, selector: #selector(handleTimer), userInfo: nil, repeats: true) 20 | 21 | let defaultHandler = swipeableView.shouldSwipeView 22 | swipeableView.shouldSwipeView = {(view: UIView, movement: Movement, swipeableView: ZLSwipeableView) in 23 | self.shouldSwipe && defaultHandler(view, movement, swipeableView) 24 | } 25 | } 26 | 27 | // MARK: - Actions 28 | 29 | @objc func handleTimer() { 30 | self.shouldSwipe = !self.shouldSwipe 31 | self.title = "Should Swipe " + (self.shouldSwipe ? "👍" : "👎") 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemo/ZLSwipeableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 4/27/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import UIColor_FlatColors 11 | import Cartography 12 | 13 | class ZLSwipeableViewController: UIViewController { 14 | 15 | var swipeableView: ZLSwipeableView! 16 | 17 | var colors = ["Turquoise", "Green Sea", "Emerald", "Nephritis", "Peter River", "Belize Hole", "Amethyst", "Wisteria", "Wet Asphalt", "Midnight Blue", "Sun Flower", "Orange", "Carrot", "Pumpkin", "Alizarin", "Pomegranate", "Clouds", "Silver", "Concrete", "Asbestos"] 18 | var colorIndex = 0 19 | var loadCardsFromXib = false 20 | 21 | var reloadBarButtonItem: UIBarButtonItem! 22 | // var reloadBarButtonItem = UIBarButtonItem(barButtonSystemItem: "Reload", target: .Plain) { item in } 23 | var leftBarButtonItem: UIBarButtonItem! 24 | // var leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: "←", target: .Plain) { item in } 25 | var upBarButtonItem: UIBarButtonItem! 26 | // var upBarButtonItem = UIBarButtonItem(barButtonSystemItem: "↑", target: .Plain) { item in } 27 | var rightBarButtonItem: UIBarButtonItem! 28 | // var rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: "→", target: .Plain) { item in } 29 | var downBarButtonItem:UIBarButtonItem! 30 | // var downBarButtonItem = UIBarButtonItem(barButtonSystemItem: "↓", target: .Plain) { item in } 31 | 32 | override func viewDidLayoutSubviews() { 33 | super.viewDidLayoutSubviews() 34 | swipeableView.nextView = { 35 | return self.nextCardView() 36 | } 37 | } 38 | 39 | override func viewDidLoad() { 40 | super.viewDidLoad() 41 | navigationController?.setToolbarHidden(false, animated: false) 42 | view.backgroundColor = UIColor.white 43 | view.clipsToBounds = true 44 | 45 | reloadBarButtonItem = UIBarButtonItem(title: "Reload", style: .plain, target: self, action: #selector(reloadButtonAction)) 46 | leftBarButtonItem = UIBarButtonItem(title: "←", style: .plain, target: self, action: #selector(leftButtonAction)) 47 | upBarButtonItem = UIBarButtonItem(title: "↑", style: .plain, target: self, action: #selector(upButtonAction)) 48 | rightBarButtonItem = UIBarButtonItem(title: "→", style: .plain, target: self, action: #selector(rightButtonAction)) 49 | downBarButtonItem = UIBarButtonItem(title: "↓", style: .plain, target: self, action: #selector(downButtonAction)) 50 | 51 | let fixedSpace = UIBarButtonItem(barButtonSystemItem: .fixedSpace, target: nil, action: nil) 52 | let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil) 53 | 54 | let items = [fixedSpace, reloadBarButtonItem!, flexibleSpace, leftBarButtonItem!, flexibleSpace, upBarButtonItem!, flexibleSpace, rightBarButtonItem!, flexibleSpace, downBarButtonItem!, fixedSpace] 55 | toolbarItems = items 56 | 57 | swipeableView = ZLSwipeableView() 58 | view.addSubview(swipeableView) 59 | swipeableView.didStart = {view, location in 60 | print("Did start swiping view at location: \(location)") 61 | } 62 | swipeableView.swiping = {view, location, translation in 63 | print("Swiping at view location: \(location) translation: \(translation)") 64 | } 65 | swipeableView.didEnd = {view, location in 66 | print("Did end swiping view at location: \(location)") 67 | } 68 | swipeableView.didSwipe = {view, direction, vector in 69 | print("Did swipe view in direction: \(direction), vector: \(vector)") 70 | } 71 | swipeableView.didCancel = {view in 72 | print("Did cancel swiping view") 73 | } 74 | swipeableView.didTap = {view, location in 75 | print("Did tap at location \(location)") 76 | } 77 | swipeableView.didDisappear = { view in 78 | print("Did disappear swiping view") 79 | } 80 | 81 | constrain(swipeableView, view) { view1, view2 in 82 | view1.left == view2.left+50 83 | view1.right == view2.right-50 84 | view1.top == view2.top + 120 85 | view1.bottom == view2.bottom - 100 86 | } 87 | } 88 | 89 | // MARK: - Actions 90 | 91 | @objc func reloadButtonAction() { 92 | let alertController = UIAlertController(title: nil, message: "Load Cards:", preferredStyle: .actionSheet) 93 | 94 | let cancelAction = UIAlertAction(title: "Cancel", style: .cancel) { (action) in 95 | // ... 96 | } 97 | alertController.addAction(cancelAction) 98 | 99 | let ProgrammaticallyAction = UIAlertAction(title: "Programmatically", style: .default) { (action) in 100 | self.loadCardsFromXib = false 101 | self.colorIndex = 0 102 | self.swipeableView.discardViews() 103 | self.swipeableView.loadViews() 104 | } 105 | alertController.addAction(ProgrammaticallyAction) 106 | 107 | let XibAction = UIAlertAction(title: "From Xib", style: .default) { (action) in 108 | self.loadCardsFromXib = true 109 | self.colorIndex = 0 110 | self.swipeableView.discardViews() 111 | self.swipeableView.loadViews() 112 | } 113 | alertController.addAction(XibAction) 114 | 115 | self.present(alertController, animated: true, completion: nil) 116 | } 117 | 118 | @objc func leftButtonAction() { 119 | self.swipeableView.swipeTopView(inDirection: .Left) 120 | } 121 | 122 | @objc func upButtonAction() { 123 | self.swipeableView.swipeTopView(inDirection: .Up) 124 | } 125 | 126 | @objc func rightButtonAction() { 127 | self.swipeableView.swipeTopView(inDirection: .Right) 128 | } 129 | 130 | @objc func downButtonAction() { 131 | self.swipeableView.swipeTopView(inDirection: .Down) 132 | } 133 | 134 | // MARK: () 135 | func nextCardView() -> UIView? { 136 | if colorIndex >= colors.count { 137 | colorIndex = 0 138 | } 139 | 140 | let cardView = CardView(frame: swipeableView.bounds) 141 | cardView.backgroundColor = colorForName(colors[colorIndex]) 142 | colorIndex += 1 143 | 144 | if loadCardsFromXib { 145 | let contentView = Bundle.main.loadNibNamed("CardContentView", owner: self, options: nil)?.first! as! UIView 146 | contentView.translatesAutoresizingMaskIntoConstraints = false 147 | contentView.backgroundColor = cardView.backgroundColor 148 | cardView.addSubview(contentView) 149 | 150 | // This is important: 151 | // https://github.com/zhxnlai/ZLSwipeableView/issues/9 152 | /*// Alternative: 153 | let metrics = ["width":cardView.bounds.width, "height": cardView.bounds.height] 154 | let views = ["contentView": contentView, "cardView": cardView] 155 | cardView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("H:|[contentView(width)]", options: .AlignAllLeft, metrics: metrics, views: views)) 156 | cardView.addConstraints(NSLayoutConstraint.constraintsWithVisualFormat("V:|[contentView(height)]", options: .AlignAllLeft, metrics: metrics, views: views)) 157 | */ 158 | constrain(contentView, cardView) { view1, view2 in 159 | view1.left == view2.left 160 | view1.top == view2.top 161 | view1.width == cardView.bounds.width 162 | view1.height == cardView.bounds.height 163 | } 164 | } 165 | return cardView 166 | } 167 | 168 | func colorForName(_ name: String) -> UIColor { 169 | let sanitizedName = name.replacingOccurrences(of: " ", with: "") 170 | let selector = "flat\(sanitizedName)Color" 171 | return UIColor.perform(Selector(selector)).takeUnretainedValue() as! UIColor 172 | } 173 | } 174 | 175 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemoTests/DirectionTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // DirectionTests.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 10/22/15. 6 | // Copyright © 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | import ZLSwipeableViewSwiftDemo 11 | 12 | class DirectionTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testFromPoint() { 25 | XCTAssertEqual(Direction.fromPoint(CGPoint(x: 1, y: 0)), Direction.Right) 26 | XCTAssertEqual(Direction.fromPoint(CGPoint(x: -1, y: 0)), Direction.Left) 27 | XCTAssertEqual(Direction.fromPoint(CGPoint(x: 0, y: -1)), Direction.Up) 28 | XCTAssertEqual(Direction.fromPoint(CGPoint(x: 0, y: 1)), Direction.Down) 29 | XCTAssertEqual(Direction.fromPoint(CGPoint(x: 0, y: 0)), Direction.None) 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemoTests/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 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemoTests/ViewManagerTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewManagerTests.swift 3 | // ZLSwipeableViewSwiftDemo 4 | // 5 | // Created by Zhixuan Lai on 10/22/15. 6 | // Copyright © 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import XCTest 10 | 11 | class ViewManagerTests: XCTestCase { 12 | 13 | override func setUp() { 14 | super.setUp() 15 | // Put setup code here. This method is called before the invocation of each test method in the class. 16 | } 17 | 18 | override func tearDown() { 19 | // Put teardown code here. This method is called after the invocation of each test method in the class. 20 | super.tearDown() 21 | } 22 | 23 | func testStateTransition() { 24 | // simulate pan gesture 25 | } 26 | 27 | func testPerformanceExample() { 28 | // This is an example of a performance test case. 29 | self.measure { 30 | // Put the code you want to measure the time of here. 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /ZLSwipeableViewSwiftDemo/ZLSwipeableViewSwiftDemoTests/ZLSwipeableViewSwiftDemoTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ZLSwipeableViewSwiftDemoTests.swift 3 | // ZLSwipeableViewSwiftDemoTests 4 | // 5 | // Created by Zhixuan Lai on 4/27/15. 6 | // Copyright (c) 2015 Zhixuan Lai. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class ZLSwipeableViewSwiftDemoTests: XCTestCase { 13 | 14 | override func setUp() { 15 | super.setUp() 16 | // Put setup code here. This method is called before the invocation of each test method in the class. 17 | } 18 | 19 | override func tearDown() { 20 | // Put teardown code here. This method is called after the invocation of each test method in the class. 21 | super.tearDown() 22 | } 23 | 24 | func testExample() { 25 | // This is an example of a functional test case. 26 | XCTAssert(true, "Pass") 27 | } 28 | 29 | func testPerformanceExample() { 30 | // This is an example of a performance test case. 31 | self.measure() { 32 | // Put the code you want to measure the time of here. 33 | } 34 | } 35 | 36 | } 37 | --------------------------------------------------------------------------------