├── .gitignore ├── .swift-version ├── LICENSE ├── README.md ├── Swiftuna.podspec ├── Swiftuna ├── Swiftuna.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── Swiftuna │ ├── Info.plist │ ├── Source │ │ ├── Swiftuna.swift │ │ └── SwiftunaOption.swift │ └── Swiftuna.h └── SwiftunaTests │ ├── Info.plist │ └── SwiftunaTests.swift └── SwiftunaExample ├── SwiftunaExample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── SwiftunaExample ├── Application │ └── AppDelegate.swift ├── Base.lproj │ ├── LaunchScreen.xib │ └── Main.storyboard ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ ├── Down.imageset │ │ ├── Contents.json │ │ └── down.png │ ├── ExampleImage.imageset │ │ ├── Contents.json │ │ └── image.png │ ├── Search.imageset │ │ ├── Contents.json │ │ └── search.png │ └── Up.imageset │ │ ├── Contents.json │ │ └── up.png ├── Info.plist ├── ViewControllers │ ├── TableViewController.swift │ └── ViewController.swift └── Views │ └── ExampleCell.swift └── SwiftunaExampleTests ├── Info.plist └── SwiftunaExampleTests.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 | 20 | .DS_Store 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 | -------------------------------------------------------------------------------- /.swift-version: -------------------------------------------------------------------------------- 1 | 3.0 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Kevin Wong 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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![SwiftunaLogo](/../github-media/media/swiftunaLogo.png?raw=true) 2 | 3 | Swiftuna is a decorator library that lets any view have a cool swipe-to-reveal options menu. 4 | 5 | ## Example 6 | 7 | ![Swiftuna](/../github-media/media/swiftuna.gif?raw=true) 8 | 9 | The example's source code can be found in the SwiftunaExample project. 10 | 11 | ## Installation 12 | 13 | ### Cocoapods: 14 | 15 | Add this to your Podfile: 16 | 17 | ```ruby 18 | pod 'Swiftuna', '~> 0.0.4' 19 | ``` 20 | 21 | ### Manual installation: 22 | 23 | 1. Add this repository as a git submodule of your project. (optional) 24 | 2. Once you have downloaded the source, add the `Swiftuna.xcodeproj` as a subproject of your main project. 25 | 3. In your main project's General tab, add the `Swiftuna.framework` as an embedded framework. 26 | 27 | Then, to use, import the `Swiftuna` framework: 28 | 29 | ```swift 30 | import Swiftuna 31 | ``` 32 | 33 | ## Usage 34 | 35 | In order to decorate a view, the first thing to do is to instantiate a `Swiftuna` instance, which is the main decorator class. This class is in charge of doing all the configuration, so any custom attributes must be configured here. The configuration of each option in the menu is done separately in the `SwiftunaOption` class. 36 | 37 | ### Adding the menu 38 | 39 | First, define an array of `SwiftunaOptions` to use: 40 | 41 | ```swift 42 | let options = [ 43 | SwiftunaOption(image: UIImage(named: "Up")!), 44 | SwiftunaOption(image: UIImage(named: "Down")!) 45 | ] 46 | ``` 47 | 48 | Each option is initialized with an image, which is what will be displayed in the menu. You can additionally change the value of the `size` property in each `SwiftunaOption` object. 49 | 50 | The next step is to attach the menu to a view. The short version: 51 | 52 | ```swift 53 | Swiftuna(targetView: anyView, options: options).attach() 54 | ``` 55 | 56 | If you want to customize the menu a bit, do it before the configuration is attached: 57 | 58 | ```swift 59 | let swiftuna = Swiftuna(targetView: anyView, options: options) 60 | swiftuna.optionsSpacing = 20 61 | swiftuna.backgroundViewColor = UIColor.whiteColor() 62 | swiftuna.attach() 63 | ``` 64 | 65 | ### Reacting to events 66 | 67 | In order to react to certain events (for example, when an option is selected), the listening class must implement the `SwiftunaDelegate` protocol: 68 | 69 | ```swift 70 | class MainController: SwiftunaDelegate { 71 | ... 72 | let swiftuna = Swiftuna(targetView: anyView, options: options) 73 | swiftuna.delegate = self 74 | ``` 75 | 76 | Then that class must implement the following method: 77 | 78 | ```swift 79 | func swiftuna(swiftuna: Swiftuna, didSelectOption option: SwiftunaOption, index: Int) 80 | ``` 81 | 82 | And optionally implement: 83 | 84 | ```swift 85 | func swiftuna(swiftuna : Swiftuna, shouldDismissAfterSelectionOfOption option : SwiftunaOption, index : Int) -> Bool 86 | ``` 87 | 88 | ## Author 89 | 90 | Comments and suggestions much welcome 91 | 92 | Kevin Wong, [@kevinwl02](https://twitter.com/kevinwl02) 93 | 94 | ## License 95 | 96 | Code distributed under the [MIT license](LICENSE) 97 | -------------------------------------------------------------------------------- /Swiftuna.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Swiftuna" 3 | s.version = "0.0.4" 4 | s.summary = "Decorator library that lets any view have a cool swipe-to-reveal options menu" 5 | s.homepage = "https://github.com/kevinwl02/Swiftuna" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.authors = {'Kevin Wong' => 'kevin.wl.02@gmail.com'} 8 | s.ios.deployment_target = "8.0" 9 | 10 | s.source = { :git => "https://github.com/kevinwl02/Swiftuna.git", :tag => "#{s.version}" } 11 | s.source_files = "Swiftuna/Swiftuna/*.{swift,h,m}", "Swiftuna/Swiftuna/**/*.{swift,h,m}" 12 | 13 | s.requires_arc = true 14 | end -------------------------------------------------------------------------------- /Swiftuna/Swiftuna.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0B8B224E1A2F9E36006A3DB6 /* Swiftuna.h in Headers */ = {isa = PBXBuildFile; fileRef = 0B8B224D1A2F9E36006A3DB6 /* Swiftuna.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | 0B8B22541A2F9E36006A3DB6 /* Swiftuna.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B8B22481A2F9E36006A3DB6 /* Swiftuna.framework */; }; 12 | 0B8B225B1A2F9E36006A3DB6 /* SwiftunaTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8B225A1A2F9E36006A3DB6 /* SwiftunaTests.swift */; }; 13 | 0B8B226D1A2FA09D006A3DB6 /* Swiftuna.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8B226B1A2FA09D006A3DB6 /* Swiftuna.swift */; }; 14 | 0B8B226E1A2FA09D006A3DB6 /* SwiftunaOption.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8B226C1A2FA09D006A3DB6 /* SwiftunaOption.swift */; }; 15 | /* End PBXBuildFile section */ 16 | 17 | /* Begin PBXContainerItemProxy section */ 18 | 0B8B22551A2F9E36006A3DB6 /* PBXContainerItemProxy */ = { 19 | isa = PBXContainerItemProxy; 20 | containerPortal = 0B8B223F1A2F9E36006A3DB6 /* Project object */; 21 | proxyType = 1; 22 | remoteGlobalIDString = 0B8B22471A2F9E36006A3DB6; 23 | remoteInfo = Swiftuna; 24 | }; 25 | /* End PBXContainerItemProxy section */ 26 | 27 | /* Begin PBXFileReference section */ 28 | 0B8B22481A2F9E36006A3DB6 /* Swiftuna.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Swiftuna.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 29 | 0B8B224C1A2F9E36006A3DB6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 30 | 0B8B224D1A2F9E36006A3DB6 /* Swiftuna.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Swiftuna.h; sourceTree = ""; }; 31 | 0B8B22531A2F9E36006A3DB6 /* SwiftunaTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftunaTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | 0B8B22591A2F9E36006A3DB6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 33 | 0B8B225A1A2F9E36006A3DB6 /* SwiftunaTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftunaTests.swift; sourceTree = ""; }; 34 | 0B8B226B1A2FA09D006A3DB6 /* Swiftuna.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Swiftuna.swift; sourceTree = ""; }; 35 | 0B8B226C1A2FA09D006A3DB6 /* SwiftunaOption.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwiftunaOption.swift; sourceTree = ""; }; 36 | /* End PBXFileReference section */ 37 | 38 | /* Begin PBXFrameworksBuildPhase section */ 39 | 0B8B22441A2F9E36006A3DB6 /* Frameworks */ = { 40 | isa = PBXFrameworksBuildPhase; 41 | buildActionMask = 2147483647; 42 | files = ( 43 | ); 44 | runOnlyForDeploymentPostprocessing = 0; 45 | }; 46 | 0B8B22501A2F9E36006A3DB6 /* Frameworks */ = { 47 | isa = PBXFrameworksBuildPhase; 48 | buildActionMask = 2147483647; 49 | files = ( 50 | 0B8B22541A2F9E36006A3DB6 /* Swiftuna.framework in Frameworks */, 51 | ); 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXFrameworksBuildPhase section */ 55 | 56 | /* Begin PBXGroup section */ 57 | 0B8B223E1A2F9E36006A3DB6 = { 58 | isa = PBXGroup; 59 | children = ( 60 | 0B8B224A1A2F9E36006A3DB6 /* Swiftuna */, 61 | 0B8B22571A2F9E36006A3DB6 /* SwiftunaTests */, 62 | 0B8B22491A2F9E36006A3DB6 /* Products */, 63 | ); 64 | sourceTree = ""; 65 | }; 66 | 0B8B22491A2F9E36006A3DB6 /* Products */ = { 67 | isa = PBXGroup; 68 | children = ( 69 | 0B8B22481A2F9E36006A3DB6 /* Swiftuna.framework */, 70 | 0B8B22531A2F9E36006A3DB6 /* SwiftunaTests.xctest */, 71 | ); 72 | name = Products; 73 | sourceTree = ""; 74 | }; 75 | 0B8B224A1A2F9E36006A3DB6 /* Swiftuna */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 0B8B224D1A2F9E36006A3DB6 /* Swiftuna.h */, 79 | 0B8B226A1A2FA07B006A3DB6 /* Source */, 80 | 0B8B224B1A2F9E36006A3DB6 /* Supporting Files */, 81 | ); 82 | path = Swiftuna; 83 | sourceTree = ""; 84 | }; 85 | 0B8B224B1A2F9E36006A3DB6 /* Supporting Files */ = { 86 | isa = PBXGroup; 87 | children = ( 88 | 0B8B224C1A2F9E36006A3DB6 /* Info.plist */, 89 | ); 90 | name = "Supporting Files"; 91 | sourceTree = ""; 92 | }; 93 | 0B8B22571A2F9E36006A3DB6 /* SwiftunaTests */ = { 94 | isa = PBXGroup; 95 | children = ( 96 | 0B8B225A1A2F9E36006A3DB6 /* SwiftunaTests.swift */, 97 | 0B8B22581A2F9E36006A3DB6 /* Supporting Files */, 98 | ); 99 | path = SwiftunaTests; 100 | sourceTree = ""; 101 | }; 102 | 0B8B22581A2F9E36006A3DB6 /* Supporting Files */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | 0B8B22591A2F9E36006A3DB6 /* Info.plist */, 106 | ); 107 | name = "Supporting Files"; 108 | sourceTree = ""; 109 | }; 110 | 0B8B226A1A2FA07B006A3DB6 /* Source */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | 0B8B226B1A2FA09D006A3DB6 /* Swiftuna.swift */, 114 | 0B8B226C1A2FA09D006A3DB6 /* SwiftunaOption.swift */, 115 | ); 116 | path = Source; 117 | sourceTree = ""; 118 | }; 119 | /* End PBXGroup section */ 120 | 121 | /* Begin PBXHeadersBuildPhase section */ 122 | 0B8B22451A2F9E36006A3DB6 /* Headers */ = { 123 | isa = PBXHeadersBuildPhase; 124 | buildActionMask = 2147483647; 125 | files = ( 126 | 0B8B224E1A2F9E36006A3DB6 /* Swiftuna.h in Headers */, 127 | ); 128 | runOnlyForDeploymentPostprocessing = 0; 129 | }; 130 | /* End PBXHeadersBuildPhase section */ 131 | 132 | /* Begin PBXNativeTarget section */ 133 | 0B8B22471A2F9E36006A3DB6 /* Swiftuna */ = { 134 | isa = PBXNativeTarget; 135 | buildConfigurationList = 0B8B225E1A2F9E36006A3DB6 /* Build configuration list for PBXNativeTarget "Swiftuna" */; 136 | buildPhases = ( 137 | 0B8B22431A2F9E36006A3DB6 /* Sources */, 138 | 0B8B22441A2F9E36006A3DB6 /* Frameworks */, 139 | 0B8B22451A2F9E36006A3DB6 /* Headers */, 140 | 0B8B22461A2F9E36006A3DB6 /* Resources */, 141 | ); 142 | buildRules = ( 143 | ); 144 | dependencies = ( 145 | ); 146 | name = Swiftuna; 147 | productName = Swiftuna; 148 | productReference = 0B8B22481A2F9E36006A3DB6 /* Swiftuna.framework */; 149 | productType = "com.apple.product-type.framework"; 150 | }; 151 | 0B8B22521A2F9E36006A3DB6 /* SwiftunaTests */ = { 152 | isa = PBXNativeTarget; 153 | buildConfigurationList = 0B8B22611A2F9E36006A3DB6 /* Build configuration list for PBXNativeTarget "SwiftunaTests" */; 154 | buildPhases = ( 155 | 0B8B224F1A2F9E36006A3DB6 /* Sources */, 156 | 0B8B22501A2F9E36006A3DB6 /* Frameworks */, 157 | 0B8B22511A2F9E36006A3DB6 /* Resources */, 158 | ); 159 | buildRules = ( 160 | ); 161 | dependencies = ( 162 | 0B8B22561A2F9E36006A3DB6 /* PBXTargetDependency */, 163 | ); 164 | name = SwiftunaTests; 165 | productName = SwiftunaTests; 166 | productReference = 0B8B22531A2F9E36006A3DB6 /* SwiftunaTests.xctest */; 167 | productType = "com.apple.product-type.bundle.unit-test"; 168 | }; 169 | /* End PBXNativeTarget section */ 170 | 171 | /* Begin PBXProject section */ 172 | 0B8B223F1A2F9E36006A3DB6 /* Project object */ = { 173 | isa = PBXProject; 174 | attributes = { 175 | LastSwiftMigration = 0700; 176 | LastSwiftUpdateCheck = 0700; 177 | LastUpgradeCheck = 0700; 178 | ORGANIZATIONNAME = "Kevin Wong"; 179 | TargetAttributes = { 180 | 0B8B22471A2F9E36006A3DB6 = { 181 | CreatedOnToolsVersion = 6.1; 182 | LastSwiftMigration = 0830; 183 | }; 184 | 0B8B22521A2F9E36006A3DB6 = { 185 | CreatedOnToolsVersion = 6.1; 186 | LastSwiftMigration = 0830; 187 | }; 188 | }; 189 | }; 190 | buildConfigurationList = 0B8B22421A2F9E36006A3DB6 /* Build configuration list for PBXProject "Swiftuna" */; 191 | compatibilityVersion = "Xcode 3.2"; 192 | developmentRegion = English; 193 | hasScannedForEncodings = 0; 194 | knownRegions = ( 195 | en, 196 | ); 197 | mainGroup = 0B8B223E1A2F9E36006A3DB6; 198 | productRefGroup = 0B8B22491A2F9E36006A3DB6 /* Products */; 199 | projectDirPath = ""; 200 | projectRoot = ""; 201 | targets = ( 202 | 0B8B22471A2F9E36006A3DB6 /* Swiftuna */, 203 | 0B8B22521A2F9E36006A3DB6 /* SwiftunaTests */, 204 | ); 205 | }; 206 | /* End PBXProject section */ 207 | 208 | /* Begin PBXResourcesBuildPhase section */ 209 | 0B8B22461A2F9E36006A3DB6 /* Resources */ = { 210 | isa = PBXResourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | ); 214 | runOnlyForDeploymentPostprocessing = 0; 215 | }; 216 | 0B8B22511A2F9E36006A3DB6 /* Resources */ = { 217 | isa = PBXResourcesBuildPhase; 218 | buildActionMask = 2147483647; 219 | files = ( 220 | ); 221 | runOnlyForDeploymentPostprocessing = 0; 222 | }; 223 | /* End PBXResourcesBuildPhase section */ 224 | 225 | /* Begin PBXSourcesBuildPhase section */ 226 | 0B8B22431A2F9E36006A3DB6 /* Sources */ = { 227 | isa = PBXSourcesBuildPhase; 228 | buildActionMask = 2147483647; 229 | files = ( 230 | 0B8B226D1A2FA09D006A3DB6 /* Swiftuna.swift in Sources */, 231 | 0B8B226E1A2FA09D006A3DB6 /* SwiftunaOption.swift in Sources */, 232 | ); 233 | runOnlyForDeploymentPostprocessing = 0; 234 | }; 235 | 0B8B224F1A2F9E36006A3DB6 /* Sources */ = { 236 | isa = PBXSourcesBuildPhase; 237 | buildActionMask = 2147483647; 238 | files = ( 239 | 0B8B225B1A2F9E36006A3DB6 /* SwiftunaTests.swift in Sources */, 240 | ); 241 | runOnlyForDeploymentPostprocessing = 0; 242 | }; 243 | /* End PBXSourcesBuildPhase section */ 244 | 245 | /* Begin PBXTargetDependency section */ 246 | 0B8B22561A2F9E36006A3DB6 /* PBXTargetDependency */ = { 247 | isa = PBXTargetDependency; 248 | target = 0B8B22471A2F9E36006A3DB6 /* Swiftuna */; 249 | targetProxy = 0B8B22551A2F9E36006A3DB6 /* PBXContainerItemProxy */; 250 | }; 251 | /* End PBXTargetDependency section */ 252 | 253 | /* Begin XCBuildConfiguration section */ 254 | 0B8B225C1A2F9E36006A3DB6 /* Debug */ = { 255 | isa = XCBuildConfiguration; 256 | buildSettings = { 257 | ALWAYS_SEARCH_USER_PATHS = NO; 258 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 259 | CLANG_CXX_LIBRARY = "libc++"; 260 | CLANG_ENABLE_MODULES = YES; 261 | CLANG_ENABLE_OBJC_ARC = YES; 262 | CLANG_WARN_BOOL_CONVERSION = YES; 263 | CLANG_WARN_CONSTANT_CONVERSION = YES; 264 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 265 | CLANG_WARN_EMPTY_BODY = YES; 266 | CLANG_WARN_ENUM_CONVERSION = YES; 267 | CLANG_WARN_INT_CONVERSION = YES; 268 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 269 | CLANG_WARN_UNREACHABLE_CODE = YES; 270 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 271 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 272 | COPY_PHASE_STRIP = NO; 273 | CURRENT_PROJECT_VERSION = 1; 274 | ENABLE_STRICT_OBJC_MSGSEND = YES; 275 | ENABLE_TESTABILITY = YES; 276 | GCC_C_LANGUAGE_STANDARD = gnu99; 277 | GCC_DYNAMIC_NO_PIC = NO; 278 | GCC_OPTIMIZATION_LEVEL = 0; 279 | GCC_PREPROCESSOR_DEFINITIONS = ( 280 | "DEBUG=1", 281 | "$(inherited)", 282 | ); 283 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 284 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 285 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 286 | GCC_WARN_UNDECLARED_SELECTOR = YES; 287 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 288 | GCC_WARN_UNUSED_FUNCTION = YES; 289 | GCC_WARN_UNUSED_VARIABLE = YES; 290 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 291 | MTL_ENABLE_DEBUG_INFO = YES; 292 | ONLY_ACTIVE_ARCH = YES; 293 | SDKROOT = iphoneos; 294 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 295 | TARGETED_DEVICE_FAMILY = "1,2"; 296 | VERSIONING_SYSTEM = "apple-generic"; 297 | VERSION_INFO_PREFIX = ""; 298 | }; 299 | name = Debug; 300 | }; 301 | 0B8B225D1A2F9E36006A3DB6 /* Release */ = { 302 | isa = XCBuildConfiguration; 303 | buildSettings = { 304 | ALWAYS_SEARCH_USER_PATHS = NO; 305 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 306 | CLANG_CXX_LIBRARY = "libc++"; 307 | CLANG_ENABLE_MODULES = YES; 308 | CLANG_ENABLE_OBJC_ARC = YES; 309 | CLANG_WARN_BOOL_CONVERSION = YES; 310 | CLANG_WARN_CONSTANT_CONVERSION = YES; 311 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 312 | CLANG_WARN_EMPTY_BODY = YES; 313 | CLANG_WARN_ENUM_CONVERSION = YES; 314 | CLANG_WARN_INT_CONVERSION = YES; 315 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 316 | CLANG_WARN_UNREACHABLE_CODE = YES; 317 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 318 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 319 | COPY_PHASE_STRIP = YES; 320 | CURRENT_PROJECT_VERSION = 1; 321 | ENABLE_NS_ASSERTIONS = NO; 322 | ENABLE_STRICT_OBJC_MSGSEND = YES; 323 | GCC_C_LANGUAGE_STANDARD = gnu99; 324 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 325 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 326 | GCC_WARN_UNDECLARED_SELECTOR = YES; 327 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 328 | GCC_WARN_UNUSED_FUNCTION = YES; 329 | GCC_WARN_UNUSED_VARIABLE = YES; 330 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 331 | MTL_ENABLE_DEBUG_INFO = NO; 332 | SDKROOT = iphoneos; 333 | TARGETED_DEVICE_FAMILY = "1,2"; 334 | VALIDATE_PRODUCT = YES; 335 | VERSIONING_SYSTEM = "apple-generic"; 336 | VERSION_INFO_PREFIX = ""; 337 | }; 338 | name = Release; 339 | }; 340 | 0B8B225F1A2F9E36006A3DB6 /* Debug */ = { 341 | isa = XCBuildConfiguration; 342 | buildSettings = { 343 | CLANG_ENABLE_MODULES = YES; 344 | DEFINES_MODULE = YES; 345 | DYLIB_COMPATIBILITY_VERSION = 1; 346 | DYLIB_CURRENT_VERSION = 1; 347 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 348 | INFOPLIST_FILE = Swiftuna/Info.plist; 349 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 350 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 351 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 352 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.kevinwl02.$(PRODUCT_NAME:rfc1034identifier)"; 353 | PRODUCT_NAME = "$(TARGET_NAME)"; 354 | SKIP_INSTALL = YES; 355 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 356 | SWIFT_VERSION = 3.0; 357 | }; 358 | name = Debug; 359 | }; 360 | 0B8B22601A2F9E36006A3DB6 /* Release */ = { 361 | isa = XCBuildConfiguration; 362 | buildSettings = { 363 | CLANG_ENABLE_MODULES = YES; 364 | DEFINES_MODULE = YES; 365 | DYLIB_COMPATIBILITY_VERSION = 1; 366 | DYLIB_CURRENT_VERSION = 1; 367 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 368 | INFOPLIST_FILE = Swiftuna/Info.plist; 369 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 370 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 371 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 372 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.kevinwl02.$(PRODUCT_NAME:rfc1034identifier)"; 373 | PRODUCT_NAME = "$(TARGET_NAME)"; 374 | SKIP_INSTALL = YES; 375 | SWIFT_VERSION = 3.0; 376 | }; 377 | name = Release; 378 | }; 379 | 0B8B22621A2F9E36006A3DB6 /* Debug */ = { 380 | isa = XCBuildConfiguration; 381 | buildSettings = { 382 | FRAMEWORK_SEARCH_PATHS = ( 383 | "$(SDKROOT)/Developer/Library/Frameworks", 384 | "$(inherited)", 385 | ); 386 | GCC_PREPROCESSOR_DEFINITIONS = ( 387 | "DEBUG=1", 388 | "$(inherited)", 389 | ); 390 | INFOPLIST_FILE = SwiftunaTests/Info.plist; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 392 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.kevinwl02.$(PRODUCT_NAME:rfc1034identifier)"; 393 | PRODUCT_NAME = "$(TARGET_NAME)"; 394 | SWIFT_VERSION = 3.0; 395 | }; 396 | name = Debug; 397 | }; 398 | 0B8B22631A2F9E36006A3DB6 /* Release */ = { 399 | isa = XCBuildConfiguration; 400 | buildSettings = { 401 | FRAMEWORK_SEARCH_PATHS = ( 402 | "$(SDKROOT)/Developer/Library/Frameworks", 403 | "$(inherited)", 404 | ); 405 | INFOPLIST_FILE = SwiftunaTests/Info.plist; 406 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 407 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.kevinwl02.$(PRODUCT_NAME:rfc1034identifier)"; 408 | PRODUCT_NAME = "$(TARGET_NAME)"; 409 | SWIFT_VERSION = 3.0; 410 | }; 411 | name = Release; 412 | }; 413 | /* End XCBuildConfiguration section */ 414 | 415 | /* Begin XCConfigurationList section */ 416 | 0B8B22421A2F9E36006A3DB6 /* Build configuration list for PBXProject "Swiftuna" */ = { 417 | isa = XCConfigurationList; 418 | buildConfigurations = ( 419 | 0B8B225C1A2F9E36006A3DB6 /* Debug */, 420 | 0B8B225D1A2F9E36006A3DB6 /* Release */, 421 | ); 422 | defaultConfigurationIsVisible = 0; 423 | defaultConfigurationName = Release; 424 | }; 425 | 0B8B225E1A2F9E36006A3DB6 /* Build configuration list for PBXNativeTarget "Swiftuna" */ = { 426 | isa = XCConfigurationList; 427 | buildConfigurations = ( 428 | 0B8B225F1A2F9E36006A3DB6 /* Debug */, 429 | 0B8B22601A2F9E36006A3DB6 /* Release */, 430 | ); 431 | defaultConfigurationIsVisible = 0; 432 | defaultConfigurationName = Release; 433 | }; 434 | 0B8B22611A2F9E36006A3DB6 /* Build configuration list for PBXNativeTarget "SwiftunaTests" */ = { 435 | isa = XCConfigurationList; 436 | buildConfigurations = ( 437 | 0B8B22621A2F9E36006A3DB6 /* Debug */, 438 | 0B8B22631A2F9E36006A3DB6 /* Release */, 439 | ); 440 | defaultConfigurationIsVisible = 0; 441 | defaultConfigurationName = Release; 442 | }; 443 | /* End XCConfigurationList section */ 444 | }; 445 | rootObject = 0B8B223F1A2F9E36006A3DB6 /* Project object */; 446 | } 447 | -------------------------------------------------------------------------------- /Swiftuna/Swiftuna.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Swiftuna/Swiftuna/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 | -------------------------------------------------------------------------------- /Swiftuna/Swiftuna/Source/Swiftuna.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Swiftuna.swift 3 | // 4 | // Copyright (c) 2014 Kevin Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | private let kAssociationKey : String = "Swiftuna.AssociationKey" 27 | private let kOptionsHorizontalSpacing : CGFloat = 5.0 28 | 29 | /** 30 | * This protocol represents the reactive behavior under interaction 31 | */ 32 | @objc public protocol SwiftunaDelegate : class { 33 | 34 | /** 35 | Method to be called whenever an option is selected 36 | 37 | - parameter swiftuna: The swiftuna object that initiated the call 38 | - parameter option: The option that was selected 39 | - parameter index: The index of the selected option 40 | 41 | - returns: Void 42 | */ 43 | func swiftuna(_ swiftuna : Swiftuna, didSelectOption option : SwiftunaOption, index : Int) 44 | 45 | /** 46 | Optional method to be called after selection of an option. 47 | Must indicate if the options view should be dismissed after selection. 48 | The default value is true. 49 | 50 | - parameter swiftuna: The swiftuna object that initiated the call 51 | - parameter option: The option that was selected 52 | - parameter index: The index of the selected option 53 | 54 | - returns: Wether the options view should be dismissed or not 55 | */ 56 | @objc optional func swiftuna(_ swiftuna : Swiftuna, shouldDismissAfterSelectionOfOption option : SwiftunaOption, index : Int) -> Bool 57 | } 58 | 59 | /** 60 | * Decorator class that sets up a view with a swipe to open options 61 | * menu 62 | */ 63 | open class Swiftuna : NSObject { 64 | 65 | //MARK: Public Variables 66 | 67 | /// The reference delegate object 68 | open weak var delegate : SwiftunaDelegate? 69 | 70 | /// The view that is decorated with the options menu 71 | open unowned var targetView : UIView { 72 | get { 73 | return _targetView 74 | } 75 | } 76 | 77 | /// A tag to identify the Swiftuna instance 78 | open var tag : AnyObject? 79 | 80 | /// The options that are represented in the menu 81 | open var options : [SwiftunaOption] { 82 | get { 83 | return _options 84 | } 85 | } 86 | 87 | /// Indicates if swiping the viw will trigger the options menu. 88 | /// By default it is true 89 | open var swipeEnabled : Bool = true 90 | 91 | /// The background color of the view that is displayed when the 92 | /// options menu is triggered. Should not be a translucent color. 93 | open var backgroundViewColor : UIColor? { 94 | get { 95 | return backgroundView.backgroundColor 96 | } 97 | set { 98 | backgroundView.backgroundColor = newValue 99 | } 100 | } 101 | 102 | /// The current spacing in between options. It defaults to 103 | /// kOptionsHorizontalSpacing 104 | open var optionsSpacing : CGFloat 105 | 106 | //MARK: Private variables 107 | 108 | fileprivate unowned var _targetView : UIView 109 | fileprivate var _options : [SwiftunaOption] 110 | fileprivate var optionsView : UIView 111 | fileprivate var didShowMenu : Bool = false 112 | fileprivate var snapshotView : UIImageView? 113 | fileprivate var dismissView : UIButton 114 | fileprivate var backgroundView : UIView 115 | 116 | //MARK: Initializers 117 | 118 | /** 119 | The main initializer of the decorator which sets up its initial properties, 120 | including default values. 121 | 122 | - parameter targetView: The view to which the swipe menu will be attached 123 | - parameter options: The options to display in the menu. The first option is 124 | displayed to the left. 125 | 126 | - returns: The initialized Swiftuna instance 127 | */ 128 | public init(targetView : UIView, options : [SwiftunaOption]) { 129 | 130 | _targetView = targetView 131 | optionsView = UIView() 132 | dismissView = UIButton() 133 | backgroundView = UIView() 134 | backgroundView.backgroundColor = UIColor.black 135 | _options = options 136 | optionsSpacing = kOptionsHorizontalSpacing 137 | 138 | super.init() 139 | } 140 | 141 | //MARK: Public methods 142 | 143 | /** 144 | This does the actual attaching and layout of the swipe menu. 145 | This should always be called after all configuration has been made. 146 | */ 147 | open func attach() { 148 | 149 | setupBackgroundView() 150 | setupDismissView() 151 | setupOptionsView() 152 | setupGestureRecognizer() 153 | attachToView() 154 | } 155 | 156 | /** 157 | Detaches the swipe menu from the target view. 158 | */ 159 | open func detach() { 160 | 161 | removeViews() 162 | optionsView.removeFromSuperview() 163 | 164 | objc_setAssociatedObject(targetView, kAssociationKey, nil, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) 165 | } 166 | 167 | /** 168 | This method resets the swipe menu to its original and untriggered 169 | state. 170 | */ 171 | open func reset() { 172 | 173 | didShowMenu = false 174 | self.dismissView.isHidden = true 175 | self.optionsView.isHidden = true 176 | self.backgroundView.isHidden = true 177 | self.snapshotView?.removeFromSuperview() 178 | 179 | for optionView in optionsView.subviews as [UIView] { 180 | optionView.transform = CGAffineTransform.identity 181 | } 182 | } 183 | 184 | /** 185 | This method updates the menu view with new options 186 | 187 | - parameter options: The new options to show 188 | */ 189 | open func refreshWithNewOptions(_ options : [SwiftunaOption]) { 190 | 191 | _options = options 192 | optionsView.removeFromSuperview() 193 | optionsView = UIView() 194 | setupOptionsView() 195 | } 196 | 197 | //MARK: Private methods - Setup 198 | 199 | fileprivate func setupOptionsView() { 200 | 201 | optionsView.frame = CGRect(x: 0, y: 0, width: 0, height: 100) 202 | optionsView.isHidden = true 203 | optionsView.translatesAutoresizingMaskIntoConstraints = false 204 | targetView.addSubview(optionsView) 205 | 206 | let optionsViewWidth = optionsViewCalculatedWidth() 207 | NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[optionsView]|", 208 | options: NSLayoutFormatOptions(), 209 | metrics: nil, 210 | views: ["optionsView": optionsView])) 211 | NSLayoutConstraint(item: optionsView, 212 | attribute: NSLayoutAttribute.width, 213 | relatedBy: NSLayoutRelation.equal, 214 | toItem: nil, 215 | attribute: NSLayoutAttribute.notAnAttribute, 216 | multiplier: 1, 217 | constant: optionsViewWidth).isActive = true 218 | NSLayoutConstraint(item: optionsView, attribute: NSLayoutAttribute.right, relatedBy: NSLayoutRelation.equal, toItem: targetView, attribute: NSLayoutAttribute.right, multiplier: 1, constant: 0).isActive = true 219 | 220 | setupOptionsWithOptionsViewWidth(optionsViewWidth) 221 | } 222 | 223 | fileprivate func setupOptionsWithOptionsViewWidth(_ optionsViewWidth : CGFloat) { 224 | 225 | var iterationCounter : Int = 0 226 | var previousOption : UIButton? 227 | 228 | for option in options { 229 | 230 | let optionItem = UIButton() 231 | optionItem.tag = iterationCounter 232 | optionItem.addTarget(self, action: #selector(Swiftuna.optionSelected(_:)), for: UIControlEvents.touchUpInside) 233 | optionItem.translatesAutoresizingMaskIntoConstraints = false 234 | optionsView.addSubview(optionItem) 235 | optionItem.setBackgroundImage(option.image, for: UIControlState()) 236 | 237 | NSLayoutConstraint(item: optionItem, attribute: NSLayoutAttribute.centerY, relatedBy: NSLayoutRelation.equal, toItem: optionsView, attribute: NSLayoutAttribute.centerY, multiplier: 1, constant: 0).isActive = true 238 | NSLayoutConstraint(item: optionItem, attribute: NSLayoutAttribute.width, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: option.size.width).isActive = true 239 | NSLayoutConstraint(item: optionItem, attribute: NSLayoutAttribute.height, relatedBy: NSLayoutRelation.equal, toItem: nil, attribute: NSLayoutAttribute.notAnAttribute, multiplier: 1, constant: option.size.height).isActive = true 240 | 241 | if previousOption != nil { 242 | 243 | NSLayoutConstraint(item: optionItem, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: previousOption, attribute: NSLayoutAttribute.right, multiplier: 1, constant: optionsSpacing).isActive = true 244 | } 245 | else { 246 | 247 | NSLayoutConstraint(item: optionItem, attribute: NSLayoutAttribute.left, relatedBy: NSLayoutRelation.equal, toItem: optionsView, attribute: NSLayoutAttribute.left, multiplier: 1, constant: optionsViewWidth).isActive = true 248 | } 249 | 250 | previousOption = optionItem 251 | iterationCounter += 1 252 | } 253 | } 254 | 255 | fileprivate func optionsViewCalculatedWidth() -> CGFloat { 256 | 257 | var width : CGFloat = 0.0 258 | for option in options { 259 | width += option.size.width 260 | } 261 | 262 | return width 263 | } 264 | 265 | fileprivate func setupDismissView() { 266 | 267 | dismissView.translatesAutoresizingMaskIntoConstraints = false 268 | targetView.addSubview(dismissView) 269 | let dismissViewLayoutDictionary = ["dismissView": dismissView] 270 | NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|[dismissView]|", options: NSLayoutFormatOptions(), metrics: nil, views: dismissViewLayoutDictionary)) 271 | NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[dismissView]|", options: NSLayoutFormatOptions(), metrics: nil, views: dismissViewLayoutDictionary)) 272 | 273 | dismissView.backgroundColor = UIColor.clear 274 | dismissView.addTarget(self, action: #selector(Swiftuna.hideOptionsView), for: UIControlEvents.touchUpInside) 275 | dismissView.isHidden = true 276 | } 277 | 278 | fileprivate func setupBackgroundView() { 279 | 280 | backgroundView.translatesAutoresizingMaskIntoConstraints = false 281 | targetView.addSubview(backgroundView) 282 | 283 | let backgroundViewDictionary = ["backgroundView": backgroundView] 284 | NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "H:|[backgroundView]|", options: NSLayoutFormatOptions(), metrics: nil, views: backgroundViewDictionary)) 285 | NSLayoutConstraint.activate(NSLayoutConstraint.constraints(withVisualFormat: "V:|[backgroundView]|", options: NSLayoutFormatOptions(), metrics: nil, views: backgroundViewDictionary)) 286 | 287 | backgroundView.isHidden = true 288 | } 289 | 290 | fileprivate func setupGestureRecognizer() { 291 | 292 | let swipeGestureRecognizer = UISwipeGestureRecognizer(target: self, action: #selector(Swiftuna.viewSwiped(_:))) 293 | swipeGestureRecognizer.direction = UISwipeGestureRecognizerDirection.left 294 | targetView.addGestureRecognizer(swipeGestureRecognizer) 295 | targetView.isUserInteractionEnabled = true 296 | } 297 | 298 | fileprivate func attachToView() { 299 | 300 | objc_setAssociatedObject(targetView, kAssociationKey, self, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) 301 | } 302 | 303 | //MARK: Private methods - Interaction 304 | 305 | func viewSwiped(_ swipeGestureRecognizer : UISwipeGestureRecognizer) { 306 | 307 | if swipeEnabled && !didShowMenu { 308 | 309 | didShowMenu = true 310 | setupSnapshotView() 311 | backgroundView.isHidden = false 312 | dismissView.isHidden = false 313 | optionsView.isHidden = false 314 | 315 | UIView.animate(withDuration: 0.3, delay: 0, usingSpringWithDamping: 0.6, initialSpringVelocity: 1, options: UIViewAnimationOptions.curveEaseOut, animations: { () -> Void in 316 | self.transformSnapshotView() 317 | }, completion: nil) 318 | 319 | var iteratorCount = 0.0 320 | for optionView in optionsView.subviews { 321 | animateOption(optionView as! UIButton, delay: iteratorCount * 0.1) 322 | iteratorCount += 1 323 | } 324 | } 325 | } 326 | 327 | fileprivate func removeViews() { 328 | 329 | optionsView.removeFromSuperview() 330 | backgroundView.removeFromSuperview() 331 | dismissView.removeFromSuperview() 332 | } 333 | 334 | func hideOptionsView() { 335 | 336 | if !didShowMenu { 337 | return 338 | } 339 | 340 | didShowMenu = false 341 | 342 | UIView.animate(withDuration: 0.3, animations: { () -> Void in 343 | self.transformBackSnapshotView() 344 | }, completion: { (completed) -> Void in 345 | if completed { 346 | self.dismissView.isHidden = true 347 | self.optionsView.isHidden = true 348 | self.backgroundView.isHidden = true 349 | self.snapshotView!.removeFromSuperview() 350 | } 351 | }) 352 | 353 | var iteratorCount = 0.0 354 | for optionView in optionsView.subviews { 355 | animateBackOption(optionView as! UIButton, delay: (Double(options.count) - iteratorCount - 1.0) * 0.1) 356 | iteratorCount += 1 357 | } 358 | } 359 | 360 | func optionSelected(_ optionItem : UIButton) { 361 | 362 | let index = optionItem.tag 363 | delegate?.swiftuna(self, didSelectOption: options[index], index: index) 364 | 365 | var shouldDismiss = true 366 | if let shouldDismissResult = delegate?.swiftuna?(self, shouldDismissAfterSelectionOfOption: options[index], index: index) { 367 | shouldDismiss = shouldDismissResult 368 | } 369 | 370 | if shouldDismiss { 371 | hideOptionsView() 372 | } 373 | } 374 | 375 | //MARK: Private methods - Animation 376 | 377 | fileprivate func animateOption(_ option : UIButton, delay : TimeInterval) { 378 | 379 | let width = optionsView.bounds.size.width + optionsSpacing * CGFloat(options.count) 380 | option.alpha = 0 381 | 382 | UIView.animate(withDuration: 0.4, delay: delay, usingSpringWithDamping: 0.8, initialSpringVelocity: 1, options: UIViewAnimationOptions.curveEaseOut, animations: { () -> Void in 383 | option.transform = option.transform.translatedBy(x: -width, y: 0) 384 | option.alpha = 1 385 | }, completion: nil) 386 | } 387 | 388 | fileprivate func animateBackOption(_ option : UIButton, delay : TimeInterval) { 389 | 390 | UIView.animate(withDuration: 0.4, delay: delay, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: UIViewAnimationOptions.curveEaseOut, animations: { () -> Void in 391 | option.transform = CGAffineTransform.identity 392 | option.alpha = 0 393 | }, completion: nil) 394 | } 395 | 396 | fileprivate func setupSnapshotView() { 397 | 398 | snapshotView = UIImageView(frame: targetView.bounds) 399 | 400 | UIGraphicsBeginImageContextWithOptions(targetView.frame.size, targetView.isOpaque, 0.0) 401 | let context = UIGraphicsGetCurrentContext() 402 | 403 | if let unwrappedContext : CGContext = context { 404 | targetView.layer.render(in: unwrappedContext) 405 | let snapshotImage = UIGraphicsGetImageFromCurrentImageContext() 406 | UIGraphicsEndImageContext() 407 | 408 | snapshotView!.image = snapshotImage 409 | } 410 | 411 | snapshotView!.layer.allowsEdgeAntialiasing = true 412 | 413 | backgroundView.addSubview(snapshotView!) 414 | 415 | if let unwrappedSnapshotView : UIImageView = snapshotView { 416 | unwrappedSnapshotView.layer.anchorPoint = CGPoint(x: 0, y: 0.5) 417 | unwrappedSnapshotView.layer.position = CGPoint(x: unwrappedSnapshotView.layer.position.x - unwrappedSnapshotView.layer.bounds.size.width / 2, y: unwrappedSnapshotView.layer.position.y) 418 | } 419 | } 420 | 421 | fileprivate func transformSnapshotView() { 422 | 423 | if let unwrappedSnapshotView : UIImageView = snapshotView { 424 | var identity = CATransform3DIdentity 425 | identity.m34 = 0.001 426 | unwrappedSnapshotView.layer.transform = CATransform3DRotate(identity, CGFloat(-20 / 180 * Double.pi), 0, 1, 0) 427 | } 428 | } 429 | 430 | fileprivate func transformBackSnapshotView() { 431 | 432 | if let unwrappedSnapshotView : UIImageView = snapshotView { 433 | 434 | unwrappedSnapshotView.layer.transform = CATransform3DIdentity 435 | } 436 | } 437 | 438 | fileprivate func setupBackSnapshotView() { 439 | 440 | if let unwrappedSnapshotView : UIImageView = snapshotView { 441 | unwrappedSnapshotView.layer.anchorPoint = CGPoint(x: 0.5, y: 0.5) 442 | unwrappedSnapshotView.layer.position = CGPoint(x: 0, y: unwrappedSnapshotView.layer.position.y) 443 | } 444 | } 445 | } 446 | -------------------------------------------------------------------------------- /Swiftuna/Swiftuna/Source/SwiftunaOption.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftunaOption.swift 3 | // 4 | // Copyright (c) 2014 Kevin Wong 5 | // 6 | // Permission is hereby granted, free of charge, to any person obtaining a copy 7 | // of this software and associated documentation files (the "Software"), to deal 8 | // in the Software without restriction, including without limitation the rights 9 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | // copies of the Software, and to permit persons to whom the Software is 11 | // furnished to do so, subject to the following conditions: 12 | // 13 | // The above copyright notice and this permission notice shall be included in 14 | // all copies or substantial portions of the Software. 15 | // 16 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | // THE SOFTWARE. 23 | 24 | import UIKit 25 | 26 | private let kButtonWidth : CGFloat = 70 27 | private let kButtonHeight : CGFloat = 70 28 | 29 | /** 30 | * This class is the representation of a selectable object in the options 31 | * view 32 | */ 33 | open class SwiftunaOption : NSObject { 34 | 35 | /// The image defines the whole graphical aspect that the option will 36 | /// display 37 | open var image : UIImage 38 | 39 | /// The display size of the option 40 | open var size : CGSize 41 | 42 | /** 43 | Initializes the option with an image to display and default size 44 | 45 | - parameter image: The image that will represent the option 46 | 47 | - returns: The initialized option 48 | */ 49 | public init(image : UIImage) { 50 | 51 | self.image = image 52 | self.size = CGSize(width: kButtonWidth, height: kButtonHeight) 53 | super.init() 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Swiftuna/Swiftuna/Swiftuna.h: -------------------------------------------------------------------------------- 1 | // 2 | // Swiftuna.h 3 | // Swiftuna 4 | // 5 | // Created by Kevin on 03/12/14. 6 | // Copyright (c) 2014 Kevin Wong. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Swiftuna. 12 | FOUNDATION_EXPORT double SwiftunaVersionNumber; 13 | 14 | //! Project version string for Swiftuna. 15 | FOUNDATION_EXPORT const unsigned char SwiftunaVersionString[]; 16 | 17 | 18 | -------------------------------------------------------------------------------- /Swiftuna/SwiftunaTests/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 | -------------------------------------------------------------------------------- /Swiftuna/SwiftunaTests/SwiftunaTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftunaTests.swift 3 | // SwiftunaTests 4 | // 5 | // Created by Kevin on 03/12/14. 6 | // Copyright (c) 2014 Kevin Wong. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class SwiftunaTests: 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 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 0B8B22B81A2FAD33006A3DB6 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 0B8B22B61A2FAD33006A3DB6 /* Main.storyboard */; }; 11 | 0B8B22BA1A2FAD33006A3DB6 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 0B8B22B91A2FAD33006A3DB6 /* Images.xcassets */; }; 12 | 0B8B22BD1A2FAD33006A3DB6 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 0B8B22BB1A2FAD33006A3DB6 /* LaunchScreen.xib */; }; 13 | 0B8B22C91A2FAD33006A3DB6 /* SwiftunaExampleTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8B22C81A2FAD33006A3DB6 /* SwiftunaExampleTests.swift */; }; 14 | 0B8B22DB1A2FAF1F006A3DB6 /* Swiftuna.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0B8B22D81A2FAF15006A3DB6 /* Swiftuna.framework */; }; 15 | 0B8B22DC1A2FAF1F006A3DB6 /* Swiftuna.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 0B8B22D81A2FAF15006A3DB6 /* Swiftuna.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 16 | 0B8B22E61A2FBDF1006A3DB6 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8B22E31A2FBDF1006A3DB6 /* AppDelegate.swift */; }; 17 | 0B8B22E71A2FBDF1006A3DB6 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8B22E51A2FBDF1006A3DB6 /* ViewController.swift */; }; 18 | 0B8B22EA1A2FC7F7006A3DB6 /* ExampleCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8B22E91A2FC7F7006A3DB6 /* ExampleCell.swift */; }; 19 | 0B8B22EC1A2FC841006A3DB6 /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0B8B22EB1A2FC841006A3DB6 /* TableViewController.swift */; }; 20 | /* End PBXBuildFile section */ 21 | 22 | /* Begin PBXContainerItemProxy section */ 23 | 0B8B22C31A2FAD33006A3DB6 /* PBXContainerItemProxy */ = { 24 | isa = PBXContainerItemProxy; 25 | containerPortal = 0B8B22A51A2FAD33006A3DB6 /* Project object */; 26 | proxyType = 1; 27 | remoteGlobalIDString = 0B8B22AC1A2FAD33006A3DB6; 28 | remoteInfo = SwiftunaExample; 29 | }; 30 | 0B8B22D71A2FAF15006A3DB6 /* PBXContainerItemProxy */ = { 31 | isa = PBXContainerItemProxy; 32 | containerPortal = 0B8B22D21A2FAF15006A3DB6 /* Swiftuna.xcodeproj */; 33 | proxyType = 2; 34 | remoteGlobalIDString = 0B8B22481A2F9E36006A3DB6; 35 | remoteInfo = Swiftuna; 36 | }; 37 | 0B8B22D91A2FAF15006A3DB6 /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = 0B8B22D21A2FAF15006A3DB6 /* Swiftuna.xcodeproj */; 40 | proxyType = 2; 41 | remoteGlobalIDString = 0B8B22531A2F9E36006A3DB6; 42 | remoteInfo = SwiftunaTests; 43 | }; 44 | 0B8B22DD1A2FAF1F006A3DB6 /* PBXContainerItemProxy */ = { 45 | isa = PBXContainerItemProxy; 46 | containerPortal = 0B8B22D21A2FAF15006A3DB6 /* Swiftuna.xcodeproj */; 47 | proxyType = 1; 48 | remoteGlobalIDString = 0B8B22471A2F9E36006A3DB6; 49 | remoteInfo = Swiftuna; 50 | }; 51 | /* End PBXContainerItemProxy section */ 52 | 53 | /* Begin PBXCopyFilesBuildPhase section */ 54 | 0B8B22DF1A2FAF1F006A3DB6 /* Embed Frameworks */ = { 55 | isa = PBXCopyFilesBuildPhase; 56 | buildActionMask = 2147483647; 57 | dstPath = ""; 58 | dstSubfolderSpec = 10; 59 | files = ( 60 | 0B8B22DC1A2FAF1F006A3DB6 /* Swiftuna.framework in Embed Frameworks */, 61 | ); 62 | name = "Embed Frameworks"; 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | /* End PBXCopyFilesBuildPhase section */ 66 | 67 | /* Begin PBXFileReference section */ 68 | 0B8B22AD1A2FAD33006A3DB6 /* SwiftunaExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = SwiftunaExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 69 | 0B8B22B11A2FAD33006A3DB6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 70 | 0B8B22B71A2FAD33006A3DB6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 71 | 0B8B22B91A2FAD33006A3DB6 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 72 | 0B8B22BC1A2FAD33006A3DB6 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 73 | 0B8B22C21A2FAD33006A3DB6 /* SwiftunaExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = SwiftunaExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 74 | 0B8B22C71A2FAD33006A3DB6 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 75 | 0B8B22C81A2FAD33006A3DB6 /* SwiftunaExampleTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SwiftunaExampleTests.swift; sourceTree = ""; }; 76 | 0B8B22D21A2FAF15006A3DB6 /* Swiftuna.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = Swiftuna.xcodeproj; path = ../Swiftuna/Swiftuna.xcodeproj; sourceTree = ""; }; 77 | 0B8B22E31A2FBDF1006A3DB6 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 78 | 0B8B22E51A2FBDF1006A3DB6 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 79 | 0B8B22E91A2FC7F7006A3DB6 /* ExampleCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ExampleCell.swift; path = Views/ExampleCell.swift; sourceTree = ""; }; 80 | 0B8B22EB1A2FC841006A3DB6 /* TableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = ""; }; 81 | /* End PBXFileReference section */ 82 | 83 | /* Begin PBXFrameworksBuildPhase section */ 84 | 0B8B22AA1A2FAD33006A3DB6 /* Frameworks */ = { 85 | isa = PBXFrameworksBuildPhase; 86 | buildActionMask = 2147483647; 87 | files = ( 88 | 0B8B22DB1A2FAF1F006A3DB6 /* Swiftuna.framework in Frameworks */, 89 | ); 90 | runOnlyForDeploymentPostprocessing = 0; 91 | }; 92 | 0B8B22BF1A2FAD33006A3DB6 /* Frameworks */ = { 93 | isa = PBXFrameworksBuildPhase; 94 | buildActionMask = 2147483647; 95 | files = ( 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | /* End PBXFrameworksBuildPhase section */ 100 | 101 | /* Begin PBXGroup section */ 102 | 0B8B22A41A2FAD33006A3DB6 = { 103 | isa = PBXGroup; 104 | children = ( 105 | 0B8B22D21A2FAF15006A3DB6 /* Swiftuna.xcodeproj */, 106 | 0B8B22AF1A2FAD33006A3DB6 /* SwiftunaExample */, 107 | 0B8B22C51A2FAD33006A3DB6 /* SwiftunaExampleTests */, 108 | 0B8B22AE1A2FAD33006A3DB6 /* Products */, 109 | ); 110 | sourceTree = ""; 111 | }; 112 | 0B8B22AE1A2FAD33006A3DB6 /* Products */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 0B8B22AD1A2FAD33006A3DB6 /* SwiftunaExample.app */, 116 | 0B8B22C21A2FAD33006A3DB6 /* SwiftunaExampleTests.xctest */, 117 | ); 118 | name = Products; 119 | sourceTree = ""; 120 | }; 121 | 0B8B22AF1A2FAD33006A3DB6 /* SwiftunaExample */ = { 122 | isa = PBXGroup; 123 | children = ( 124 | 0B8B22E81A2FBDFA006A3DB6 /* Views */, 125 | 0B8B22E21A2FBDF1006A3DB6 /* Application */, 126 | 0B8B22E41A2FBDF1006A3DB6 /* ViewControllers */, 127 | 0B8B22B91A2FAD33006A3DB6 /* Images.xcassets */, 128 | 0B8B22B01A2FAD33006A3DB6 /* Supporting Files */, 129 | ); 130 | path = SwiftunaExample; 131 | sourceTree = ""; 132 | }; 133 | 0B8B22B01A2FAD33006A3DB6 /* Supporting Files */ = { 134 | isa = PBXGroup; 135 | children = ( 136 | 0B8B22B11A2FAD33006A3DB6 /* Info.plist */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | 0B8B22C51A2FAD33006A3DB6 /* SwiftunaExampleTests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 0B8B22C81A2FAD33006A3DB6 /* SwiftunaExampleTests.swift */, 145 | 0B8B22C61A2FAD33006A3DB6 /* Supporting Files */, 146 | ); 147 | path = SwiftunaExampleTests; 148 | sourceTree = ""; 149 | }; 150 | 0B8B22C61A2FAD33006A3DB6 /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 0B8B22C71A2FAD33006A3DB6 /* Info.plist */, 154 | ); 155 | name = "Supporting Files"; 156 | sourceTree = ""; 157 | }; 158 | 0B8B22D31A2FAF15006A3DB6 /* Products */ = { 159 | isa = PBXGroup; 160 | children = ( 161 | 0B8B22D81A2FAF15006A3DB6 /* Swiftuna.framework */, 162 | 0B8B22DA1A2FAF15006A3DB6 /* SwiftunaTests.xctest */, 163 | ); 164 | name = Products; 165 | sourceTree = ""; 166 | }; 167 | 0B8B22E21A2FBDF1006A3DB6 /* Application */ = { 168 | isa = PBXGroup; 169 | children = ( 170 | 0B8B22E31A2FBDF1006A3DB6 /* AppDelegate.swift */, 171 | ); 172 | path = Application; 173 | sourceTree = ""; 174 | }; 175 | 0B8B22E41A2FBDF1006A3DB6 /* ViewControllers */ = { 176 | isa = PBXGroup; 177 | children = ( 178 | 0B8B22E51A2FBDF1006A3DB6 /* ViewController.swift */, 179 | 0B8B22EB1A2FC841006A3DB6 /* TableViewController.swift */, 180 | ); 181 | path = ViewControllers; 182 | sourceTree = ""; 183 | }; 184 | 0B8B22E81A2FBDFA006A3DB6 /* Views */ = { 185 | isa = PBXGroup; 186 | children = ( 187 | 0B8B22B61A2FAD33006A3DB6 /* Main.storyboard */, 188 | 0B8B22BB1A2FAD33006A3DB6 /* LaunchScreen.xib */, 189 | 0B8B22E91A2FC7F7006A3DB6 /* ExampleCell.swift */, 190 | ); 191 | name = Views; 192 | sourceTree = ""; 193 | }; 194 | /* End PBXGroup section */ 195 | 196 | /* Begin PBXNativeTarget section */ 197 | 0B8B22AC1A2FAD33006A3DB6 /* SwiftunaExample */ = { 198 | isa = PBXNativeTarget; 199 | buildConfigurationList = 0B8B22CC1A2FAD33006A3DB6 /* Build configuration list for PBXNativeTarget "SwiftunaExample" */; 200 | buildPhases = ( 201 | 0B8B22A91A2FAD33006A3DB6 /* Sources */, 202 | 0B8B22AA1A2FAD33006A3DB6 /* Frameworks */, 203 | 0B8B22AB1A2FAD33006A3DB6 /* Resources */, 204 | 0B8B22DF1A2FAF1F006A3DB6 /* Embed Frameworks */, 205 | ); 206 | buildRules = ( 207 | ); 208 | dependencies = ( 209 | 0B8B22DE1A2FAF1F006A3DB6 /* PBXTargetDependency */, 210 | ); 211 | name = SwiftunaExample; 212 | productName = SwiftunaExample; 213 | productReference = 0B8B22AD1A2FAD33006A3DB6 /* SwiftunaExample.app */; 214 | productType = "com.apple.product-type.application"; 215 | }; 216 | 0B8B22C11A2FAD33006A3DB6 /* SwiftunaExampleTests */ = { 217 | isa = PBXNativeTarget; 218 | buildConfigurationList = 0B8B22CF1A2FAD33006A3DB6 /* Build configuration list for PBXNativeTarget "SwiftunaExampleTests" */; 219 | buildPhases = ( 220 | 0B8B22BE1A2FAD33006A3DB6 /* Sources */, 221 | 0B8B22BF1A2FAD33006A3DB6 /* Frameworks */, 222 | 0B8B22C01A2FAD33006A3DB6 /* Resources */, 223 | ); 224 | buildRules = ( 225 | ); 226 | dependencies = ( 227 | 0B8B22C41A2FAD33006A3DB6 /* PBXTargetDependency */, 228 | ); 229 | name = SwiftunaExampleTests; 230 | productName = SwiftunaExampleTests; 231 | productReference = 0B8B22C21A2FAD33006A3DB6 /* SwiftunaExampleTests.xctest */; 232 | productType = "com.apple.product-type.bundle.unit-test"; 233 | }; 234 | /* End PBXNativeTarget section */ 235 | 236 | /* Begin PBXProject section */ 237 | 0B8B22A51A2FAD33006A3DB6 /* Project object */ = { 238 | isa = PBXProject; 239 | attributes = { 240 | LastSwiftMigration = 0700; 241 | LastSwiftUpdateCheck = 0700; 242 | LastUpgradeCheck = 0700; 243 | ORGANIZATIONNAME = "Kevin Wong"; 244 | TargetAttributes = { 245 | 0B8B22AC1A2FAD33006A3DB6 = { 246 | CreatedOnToolsVersion = 6.1; 247 | LastSwiftMigration = 0830; 248 | }; 249 | 0B8B22C11A2FAD33006A3DB6 = { 250 | CreatedOnToolsVersion = 6.1; 251 | LastSwiftMigration = 0830; 252 | TestTargetID = 0B8B22AC1A2FAD33006A3DB6; 253 | }; 254 | }; 255 | }; 256 | buildConfigurationList = 0B8B22A81A2FAD33006A3DB6 /* Build configuration list for PBXProject "SwiftunaExample" */; 257 | compatibilityVersion = "Xcode 3.2"; 258 | developmentRegion = English; 259 | hasScannedForEncodings = 0; 260 | knownRegions = ( 261 | en, 262 | Base, 263 | ); 264 | mainGroup = 0B8B22A41A2FAD33006A3DB6; 265 | productRefGroup = 0B8B22AE1A2FAD33006A3DB6 /* Products */; 266 | projectDirPath = ""; 267 | projectReferences = ( 268 | { 269 | ProductGroup = 0B8B22D31A2FAF15006A3DB6 /* Products */; 270 | ProjectRef = 0B8B22D21A2FAF15006A3DB6 /* Swiftuna.xcodeproj */; 271 | }, 272 | ); 273 | projectRoot = ""; 274 | targets = ( 275 | 0B8B22AC1A2FAD33006A3DB6 /* SwiftunaExample */, 276 | 0B8B22C11A2FAD33006A3DB6 /* SwiftunaExampleTests */, 277 | ); 278 | }; 279 | /* End PBXProject section */ 280 | 281 | /* Begin PBXReferenceProxy section */ 282 | 0B8B22D81A2FAF15006A3DB6 /* Swiftuna.framework */ = { 283 | isa = PBXReferenceProxy; 284 | fileType = wrapper.framework; 285 | path = Swiftuna.framework; 286 | remoteRef = 0B8B22D71A2FAF15006A3DB6 /* PBXContainerItemProxy */; 287 | sourceTree = BUILT_PRODUCTS_DIR; 288 | }; 289 | 0B8B22DA1A2FAF15006A3DB6 /* SwiftunaTests.xctest */ = { 290 | isa = PBXReferenceProxy; 291 | fileType = wrapper.cfbundle; 292 | path = SwiftunaTests.xctest; 293 | remoteRef = 0B8B22D91A2FAF15006A3DB6 /* PBXContainerItemProxy */; 294 | sourceTree = BUILT_PRODUCTS_DIR; 295 | }; 296 | /* End PBXReferenceProxy section */ 297 | 298 | /* Begin PBXResourcesBuildPhase section */ 299 | 0B8B22AB1A2FAD33006A3DB6 /* Resources */ = { 300 | isa = PBXResourcesBuildPhase; 301 | buildActionMask = 2147483647; 302 | files = ( 303 | 0B8B22B81A2FAD33006A3DB6 /* Main.storyboard in Resources */, 304 | 0B8B22BD1A2FAD33006A3DB6 /* LaunchScreen.xib in Resources */, 305 | 0B8B22BA1A2FAD33006A3DB6 /* Images.xcassets in Resources */, 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | 0B8B22C01A2FAD33006A3DB6 /* Resources */ = { 310 | isa = PBXResourcesBuildPhase; 311 | buildActionMask = 2147483647; 312 | files = ( 313 | ); 314 | runOnlyForDeploymentPostprocessing = 0; 315 | }; 316 | /* End PBXResourcesBuildPhase section */ 317 | 318 | /* Begin PBXSourcesBuildPhase section */ 319 | 0B8B22A91A2FAD33006A3DB6 /* Sources */ = { 320 | isa = PBXSourcesBuildPhase; 321 | buildActionMask = 2147483647; 322 | files = ( 323 | 0B8B22EA1A2FC7F7006A3DB6 /* ExampleCell.swift in Sources */, 324 | 0B8B22E71A2FBDF1006A3DB6 /* ViewController.swift in Sources */, 325 | 0B8B22E61A2FBDF1006A3DB6 /* AppDelegate.swift in Sources */, 326 | 0B8B22EC1A2FC841006A3DB6 /* TableViewController.swift in Sources */, 327 | ); 328 | runOnlyForDeploymentPostprocessing = 0; 329 | }; 330 | 0B8B22BE1A2FAD33006A3DB6 /* Sources */ = { 331 | isa = PBXSourcesBuildPhase; 332 | buildActionMask = 2147483647; 333 | files = ( 334 | 0B8B22C91A2FAD33006A3DB6 /* SwiftunaExampleTests.swift in Sources */, 335 | ); 336 | runOnlyForDeploymentPostprocessing = 0; 337 | }; 338 | /* End PBXSourcesBuildPhase section */ 339 | 340 | /* Begin PBXTargetDependency section */ 341 | 0B8B22C41A2FAD33006A3DB6 /* PBXTargetDependency */ = { 342 | isa = PBXTargetDependency; 343 | target = 0B8B22AC1A2FAD33006A3DB6 /* SwiftunaExample */; 344 | targetProxy = 0B8B22C31A2FAD33006A3DB6 /* PBXContainerItemProxy */; 345 | }; 346 | 0B8B22DE1A2FAF1F006A3DB6 /* PBXTargetDependency */ = { 347 | isa = PBXTargetDependency; 348 | name = Swiftuna; 349 | targetProxy = 0B8B22DD1A2FAF1F006A3DB6 /* PBXContainerItemProxy */; 350 | }; 351 | /* End PBXTargetDependency section */ 352 | 353 | /* Begin PBXVariantGroup section */ 354 | 0B8B22B61A2FAD33006A3DB6 /* Main.storyboard */ = { 355 | isa = PBXVariantGroup; 356 | children = ( 357 | 0B8B22B71A2FAD33006A3DB6 /* Base */, 358 | ); 359 | name = Main.storyboard; 360 | sourceTree = ""; 361 | }; 362 | 0B8B22BB1A2FAD33006A3DB6 /* LaunchScreen.xib */ = { 363 | isa = PBXVariantGroup; 364 | children = ( 365 | 0B8B22BC1A2FAD33006A3DB6 /* Base */, 366 | ); 367 | name = LaunchScreen.xib; 368 | sourceTree = ""; 369 | }; 370 | /* End PBXVariantGroup section */ 371 | 372 | /* Begin XCBuildConfiguration section */ 373 | 0B8B22CA1A2FAD33006A3DB6 /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ALWAYS_SEARCH_USER_PATHS = NO; 377 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 378 | CLANG_CXX_LIBRARY = "libc++"; 379 | CLANG_ENABLE_MODULES = YES; 380 | CLANG_ENABLE_OBJC_ARC = YES; 381 | CLANG_WARN_BOOL_CONVERSION = YES; 382 | CLANG_WARN_CONSTANT_CONVERSION = YES; 383 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 384 | CLANG_WARN_EMPTY_BODY = YES; 385 | CLANG_WARN_ENUM_CONVERSION = YES; 386 | CLANG_WARN_INT_CONVERSION = YES; 387 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 388 | CLANG_WARN_UNREACHABLE_CODE = YES; 389 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 390 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 391 | COPY_PHASE_STRIP = NO; 392 | ENABLE_STRICT_OBJC_MSGSEND = YES; 393 | ENABLE_TESTABILITY = YES; 394 | GCC_C_LANGUAGE_STANDARD = gnu99; 395 | GCC_DYNAMIC_NO_PIC = NO; 396 | GCC_OPTIMIZATION_LEVEL = 0; 397 | GCC_PREPROCESSOR_DEFINITIONS = ( 398 | "DEBUG=1", 399 | "$(inherited)", 400 | ); 401 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 402 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 403 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 404 | GCC_WARN_UNDECLARED_SELECTOR = YES; 405 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 406 | GCC_WARN_UNUSED_FUNCTION = YES; 407 | GCC_WARN_UNUSED_VARIABLE = YES; 408 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 409 | MTL_ENABLE_DEBUG_INFO = YES; 410 | ONLY_ACTIVE_ARCH = YES; 411 | SDKROOT = iphoneos; 412 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 413 | TARGETED_DEVICE_FAMILY = "1,2"; 414 | }; 415 | name = Debug; 416 | }; 417 | 0B8B22CB1A2FAD33006A3DB6 /* Release */ = { 418 | isa = XCBuildConfiguration; 419 | buildSettings = { 420 | ALWAYS_SEARCH_USER_PATHS = NO; 421 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 422 | CLANG_CXX_LIBRARY = "libc++"; 423 | CLANG_ENABLE_MODULES = YES; 424 | CLANG_ENABLE_OBJC_ARC = YES; 425 | CLANG_WARN_BOOL_CONVERSION = YES; 426 | CLANG_WARN_CONSTANT_CONVERSION = YES; 427 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 428 | CLANG_WARN_EMPTY_BODY = YES; 429 | CLANG_WARN_ENUM_CONVERSION = YES; 430 | CLANG_WARN_INT_CONVERSION = YES; 431 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 432 | CLANG_WARN_UNREACHABLE_CODE = YES; 433 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 434 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 435 | COPY_PHASE_STRIP = YES; 436 | ENABLE_NS_ASSERTIONS = NO; 437 | ENABLE_STRICT_OBJC_MSGSEND = YES; 438 | GCC_C_LANGUAGE_STANDARD = gnu99; 439 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 440 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 441 | GCC_WARN_UNDECLARED_SELECTOR = YES; 442 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 443 | GCC_WARN_UNUSED_FUNCTION = YES; 444 | GCC_WARN_UNUSED_VARIABLE = YES; 445 | IPHONEOS_DEPLOYMENT_TARGET = 8.1; 446 | MTL_ENABLE_DEBUG_INFO = NO; 447 | SDKROOT = iphoneos; 448 | TARGETED_DEVICE_FAMILY = "1,2"; 449 | VALIDATE_PRODUCT = YES; 450 | }; 451 | name = Release; 452 | }; 453 | 0B8B22CD1A2FAD33006A3DB6 /* Debug */ = { 454 | isa = XCBuildConfiguration; 455 | buildSettings = { 456 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 457 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 458 | INFOPLIST_FILE = SwiftunaExample/Info.plist; 459 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 460 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.kevinwl02.$(PRODUCT_NAME:rfc1034identifier)"; 461 | PRODUCT_NAME = "$(TARGET_NAME)"; 462 | SWIFT_VERSION = 3.0; 463 | }; 464 | name = Debug; 465 | }; 466 | 0B8B22CE1A2FAD33006A3DB6 /* Release */ = { 467 | isa = XCBuildConfiguration; 468 | buildSettings = { 469 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 470 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 471 | INFOPLIST_FILE = SwiftunaExample/Info.plist; 472 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 473 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.kevinwl02.$(PRODUCT_NAME:rfc1034identifier)"; 474 | PRODUCT_NAME = "$(TARGET_NAME)"; 475 | SWIFT_VERSION = 3.0; 476 | }; 477 | name = Release; 478 | }; 479 | 0B8B22D01A2FAD33006A3DB6 /* Debug */ = { 480 | isa = XCBuildConfiguration; 481 | buildSettings = { 482 | BUNDLE_LOADER = "$(TEST_HOST)"; 483 | FRAMEWORK_SEARCH_PATHS = ( 484 | "$(SDKROOT)/Developer/Library/Frameworks", 485 | "$(inherited)", 486 | ); 487 | GCC_PREPROCESSOR_DEFINITIONS = ( 488 | "DEBUG=1", 489 | "$(inherited)", 490 | ); 491 | INFOPLIST_FILE = SwiftunaExampleTests/Info.plist; 492 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 493 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.kevinwl02.$(PRODUCT_NAME:rfc1034identifier)"; 494 | PRODUCT_NAME = "$(TARGET_NAME)"; 495 | SWIFT_VERSION = 3.0; 496 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftunaExample.app/SwiftunaExample"; 497 | }; 498 | name = Debug; 499 | }; 500 | 0B8B22D11A2FAD33006A3DB6 /* Release */ = { 501 | isa = XCBuildConfiguration; 502 | buildSettings = { 503 | BUNDLE_LOADER = "$(TEST_HOST)"; 504 | FRAMEWORK_SEARCH_PATHS = ( 505 | "$(SDKROOT)/Developer/Library/Frameworks", 506 | "$(inherited)", 507 | ); 508 | INFOPLIST_FILE = SwiftunaExampleTests/Info.plist; 509 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 510 | PRODUCT_BUNDLE_IDENTIFIER = "com.github.kevinwl02.$(PRODUCT_NAME:rfc1034identifier)"; 511 | PRODUCT_NAME = "$(TARGET_NAME)"; 512 | SWIFT_VERSION = 3.0; 513 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SwiftunaExample.app/SwiftunaExample"; 514 | }; 515 | name = Release; 516 | }; 517 | /* End XCBuildConfiguration section */ 518 | 519 | /* Begin XCConfigurationList section */ 520 | 0B8B22A81A2FAD33006A3DB6 /* Build configuration list for PBXProject "SwiftunaExample" */ = { 521 | isa = XCConfigurationList; 522 | buildConfigurations = ( 523 | 0B8B22CA1A2FAD33006A3DB6 /* Debug */, 524 | 0B8B22CB1A2FAD33006A3DB6 /* Release */, 525 | ); 526 | defaultConfigurationIsVisible = 0; 527 | defaultConfigurationName = Release; 528 | }; 529 | 0B8B22CC1A2FAD33006A3DB6 /* Build configuration list for PBXNativeTarget "SwiftunaExample" */ = { 530 | isa = XCConfigurationList; 531 | buildConfigurations = ( 532 | 0B8B22CD1A2FAD33006A3DB6 /* Debug */, 533 | 0B8B22CE1A2FAD33006A3DB6 /* Release */, 534 | ); 535 | defaultConfigurationIsVisible = 0; 536 | defaultConfigurationName = Release; 537 | }; 538 | 0B8B22CF1A2FAD33006A3DB6 /* Build configuration list for PBXNativeTarget "SwiftunaExampleTests" */ = { 539 | isa = XCConfigurationList; 540 | buildConfigurations = ( 541 | 0B8B22D01A2FAD33006A3DB6 /* Debug */, 542 | 0B8B22D11A2FAD33006A3DB6 /* Release */, 543 | ); 544 | defaultConfigurationIsVisible = 0; 545 | defaultConfigurationName = Release; 546 | }; 547 | /* End XCConfigurationList section */ 548 | }; 549 | rootObject = 0B8B22A51A2FAD33006A3DB6 /* Project object */; 550 | } 551 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Application/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // SwiftunaExample 4 | // 5 | // Created by Kevin on 03/12/14. 6 | // Copyright (c) 2014 Kevin Wong. 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: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 18 | // Override point for customization after application launch. 19 | return true 20 | } 21 | 22 | func applicationWillResignActive(_ application: UIApplication) { 23 | // 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. 24 | // 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. 25 | } 26 | 27 | func applicationDidEnterBackground(_ application: UIApplication) { 28 | // 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. 29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 30 | } 31 | 32 | func applicationWillEnterForeground(_ application: UIApplication) { 33 | // 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. 34 | } 35 | 36 | func applicationDidBecomeActive(_ application: UIApplication) { 37 | // 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. 38 | } 39 | 40 | func applicationWillTerminate(_ application: UIApplication) { 41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 42 | } 43 | 44 | 45 | } 46 | 47 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 55 | 61 | 67 | 73 | 79 | 85 | 91 | 98 | 104 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 172 | 173 | 174 | 175 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/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 | "idiom" : "ipad", 35 | "size" : "29x29", 36 | "scale" : "1x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "29x29", 41 | "scale" : "2x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "40x40", 46 | "scale" : "1x" 47 | }, 48 | { 49 | "idiom" : "ipad", 50 | "size" : "40x40", 51 | "scale" : "2x" 52 | }, 53 | { 54 | "idiom" : "ipad", 55 | "size" : "76x76", 56 | "scale" : "1x" 57 | }, 58 | { 59 | "idiom" : "ipad", 60 | "size" : "76x76", 61 | "scale" : "2x" 62 | } 63 | ], 64 | "info" : { 65 | "version" : 1, 66 | "author" : "xcode" 67 | } 68 | } -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Images.xcassets/Down.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "down.png" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Images.xcassets/Down.imageset/down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinwl02/Swiftuna/5adf115e2c7d41fda258a57e6c718fa6ae951554/SwiftunaExample/SwiftunaExample/Images.xcassets/Down.imageset/down.png -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Images.xcassets/ExampleImage.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x", 10 | "filename" : "image.png" 11 | }, 12 | { 13 | "idiom" : "universal", 14 | "scale" : "3x" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Images.xcassets/ExampleImage.imageset/image.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinwl02/Swiftuna/5adf115e2c7d41fda258a57e6c718fa6ae951554/SwiftunaExample/SwiftunaExample/Images.xcassets/ExampleImage.imageset/image.png -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Images.xcassets/Search.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "search.png" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Images.xcassets/Search.imageset/search.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinwl02/Swiftuna/5adf115e2c7d41fda258a57e6c718fa6ae951554/SwiftunaExample/SwiftunaExample/Images.xcassets/Search.imageset/search.png -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Images.xcassets/Up.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "scale" : "1x" 6 | }, 7 | { 8 | "idiom" : "universal", 9 | "scale" : "2x" 10 | }, 11 | { 12 | "idiom" : "universal", 13 | "scale" : "3x", 14 | "filename" : "up.png" 15 | } 16 | ], 17 | "info" : { 18 | "version" : 1, 19 | "author" : "xcode" 20 | } 21 | } -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Images.xcassets/Up.imageset/up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/kevinwl02/Swiftuna/5adf115e2c7d41fda258a57e6c718fa6ae951554/SwiftunaExample/SwiftunaExample/Images.xcassets/Up.imageset/up.png -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | $(PRODUCT_BUNDLE_IDENTIFIER) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | UISupportedInterfaceOrientations~ipad 40 | 41 | UIInterfaceOrientationPortrait 42 | UIInterfaceOrientationPortraitUpsideDown 43 | UIInterfaceOrientationLandscapeLeft 44 | UIInterfaceOrientationLandscapeRight 45 | 46 | 47 | 48 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/ViewControllers/TableViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // TableViewController.swift 3 | // SwiftunaExample 4 | // 5 | // Created by Kevin on 03/12/14. 6 | // Copyright (c) 2014 Kevin Wong. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Swiftuna 11 | 12 | private let kExampleCellIdentifier = "ExampleCell" 13 | 14 | class TableViewController: UITableViewController { 15 | 16 | //MARK: UITableViewDelegate 17 | 18 | override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { 19 | 20 | return 5 21 | } 22 | 23 | override func numberOfSections(in tableView: UITableView) -> Int { 24 | 25 | return 1 26 | } 27 | 28 | //MARK: UITableViewDataSource 29 | 30 | override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { 31 | 32 | let cell = tableView.dequeueReusableCell(withIdentifier: kExampleCellIdentifier) as! ExampleCell 33 | 34 | cell.exampleTitleLabel.text = String(format: "Title for item number %d", indexPath.row) 35 | cell.exampleDescriptionLabel.text = String(format: "Description for item number %d", indexPath.row) 36 | decorateCell(cell) 37 | 38 | return cell 39 | } 40 | 41 | //MARK: Private methods 42 | 43 | fileprivate func decorateCell(_ cell : UITableViewCell) { 44 | 45 | let options = [ 46 | SwiftunaOption(image: UIImage(named: "Search")!), 47 | SwiftunaOption(image: UIImage(named: "Up")!), 48 | SwiftunaOption(image: UIImage(named: "Down")!) 49 | ] 50 | Swiftuna(targetView: cell, options: options).attach() 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/ViewControllers/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // SwiftunaExample 4 | // 5 | // Created by Kevin on 03/12/14. 6 | // Copyright (c) 2014 Kevin Wong. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Swiftuna 11 | 12 | private let kShowTableSegueIdentifier = "ShowTableSegue" 13 | 14 | class ViewController: UIViewController, SwiftunaDelegate { 15 | 16 | @IBOutlet weak var compoundView: UIView! 17 | @IBOutlet weak var imageView: UIImageView! 18 | @IBOutlet weak var label: UILabel! 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | 22 | decorateViews() 23 | } 24 | 25 | //MARK: Private methods 26 | 27 | fileprivate func decorateViews() { 28 | 29 | let labelOptions = [ 30 | SwiftunaOption(image: UIImage(named: "Search")!) 31 | ] 32 | 33 | let likeOptions = [ 34 | SwiftunaOption(image: UIImage(named: "Up")!), 35 | SwiftunaOption(image: UIImage(named: "Down")!) 36 | ] 37 | 38 | let labelSwiftuna = Swiftuna(targetView: label, options: labelOptions) 39 | labelSwiftuna.backgroundViewColor = UIColor.white 40 | labelSwiftuna.delegate = self 41 | labelSwiftuna.attach() 42 | 43 | Swiftuna(targetView: imageView, options: likeOptions).attach() 44 | 45 | let viewSwiftuna = Swiftuna(targetView: compoundView, options: likeOptions) 46 | viewSwiftuna.optionsSpacing = 20 47 | viewSwiftuna.backgroundViewColor = UIColor.white 48 | viewSwiftuna.attach() 49 | } 50 | 51 | //MARK: SwiftunaDelegate 52 | 53 | func swiftuna(_ swiftuna: Swiftuna, didSelectOption option: SwiftunaOption, index: Int) { 54 | 55 | performSegue(withIdentifier: kShowTableSegueIdentifier, sender: nil) 56 | } 57 | 58 | } 59 | 60 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExample/Views/ExampleCell.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ExampleCell.swift 3 | // SwiftunaExample 4 | // 5 | // Created by Kevin on 03/12/14. 6 | // Copyright (c) 2014 Kevin Wong. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class ExampleCell: UITableViewCell { 12 | 13 | @IBOutlet weak var exampleTitleLabel: UILabel! 14 | @IBOutlet weak var exampleDescriptionLabel: UILabel! 15 | 16 | } 17 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExampleTests/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 | -------------------------------------------------------------------------------- /SwiftunaExample/SwiftunaExampleTests/SwiftunaExampleTests.swift: -------------------------------------------------------------------------------- 1 | // 2 | // SwiftunaExampleTests.swift 3 | // SwiftunaExampleTests 4 | // 5 | // Created by Kevin on 03/12/14. 6 | // Copyright (c) 2014 Kevin Wong. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import XCTest 11 | 12 | class SwiftunaExampleTests: 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 | --------------------------------------------------------------------------------