├── .gitignore ├── LICENSE ├── Mountain.podspec ├── Mountain.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── Mountain.xcscheme ├── Mountain ├── Climbing.swift ├── Info.plist ├── Information.swift ├── Mountain.h ├── Mountain.swift ├── MountainLayer.swift ├── MountainLayerHaving.swift ├── UIApplicationExtension.swift └── UIViewExtension.swift ├── MountainView.podspec ├── MountainView.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── MountainView.xcscheme ├── MountainView ├── CrossView.swift ├── CurveView.swift ├── GridView.swift ├── Info.plist ├── InformationView.swift ├── MountainView.h └── MountainView.swift ├── MountainViewExample ├── MountainViewExample.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ └── IDEWorkspaceChecks.plist └── MountainViewExample │ ├── AppDelegate.swift │ ├── Assets.xcassets │ └── AppIcon.appiconset │ │ └── Contents.json │ ├── Base.lproj │ ├── LaunchScreen.storyboard │ └── Main.storyboard │ ├── Info.plist │ ├── MountainViewController.swift │ ├── NavigationController.swift │ ├── Storyboard.swift │ └── ViewController.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore 4 | 5 | ## Build generated 6 | build/ 7 | DerivedData/ 8 | 9 | ## Various settings 10 | *.pbxuser 11 | !default.pbxuser 12 | *.mode1v3 13 | !default.mode1v3 14 | *.mode2v3 15 | !default.mode2v3 16 | *.perspectivev3 17 | !default.perspectivev3 18 | xcuserdata/ 19 | 20 | ## Other 21 | *.moved-aside 22 | *.xcuserstate 23 | 24 | ## Obj-C/Swift specific 25 | *.hmap 26 | *.ipa 27 | *.dSYM.zip 28 | *.dSYM 29 | 30 | ## Playgrounds 31 | timeline.xctimeline 32 | playground.xcworkspace 33 | 34 | # Swift Package Manager 35 | # 36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies. 37 | # Packages/ 38 | .build/ 39 | 40 | # CocoaPods 41 | # 42 | # We recommend against adding the Pods directory to your .gitignore. However 43 | # you should judge for yourself, the pros and cons are mentioned at: 44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control 45 | # 46 | # Pods/ 47 | 48 | # Carthage 49 | # 50 | # Add this line if you want to avoid checking in source code from Carthage dependencies. 51 | # Carthage/Checkouts 52 | 53 | Carthage/Build 54 | 55 | # fastlane 56 | # 57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the 58 | # screenshots whenever they are needed. 59 | # For more information about the recommended setup visit: 60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md 61 | 62 | fastlane/report.xml 63 | fastlane/Preview.html 64 | fastlane/screenshots 65 | fastlane/test_output 66 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2016 Kyohei Ito 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 | -------------------------------------------------------------------------------- /Mountain.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Mountain" 3 | s.summary = "The animation curve looks like Mountain View." 4 | s.homepage = "https://github.com/KyoheiG3/MountainView" 5 | s.version = "0.2.0" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.author = { "Kyohei Ito" => "je.suis.kyohei@gmail.com" } 8 | s.swift_version = '4.2' 9 | s.ios.deployment_target = '9.0' 10 | s.tvos.deployment_target = '9.0' 11 | s.source = { :git => "https://github.com/KyoheiG3/MountainView.git", :tag => s.version.to_s } 12 | s.source_files = "Mountain/**/*.{h,swift}" 13 | s.requires_arc = true 14 | s.frameworks = "UIKit" 15 | end 16 | -------------------------------------------------------------------------------- /Mountain.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C7BB12651DF57D8600228A8D /* Mountain.h in Headers */ = {isa = PBXBuildFile; fileRef = C7BB12631DF57D8600228A8D /* Mountain.h */; settings = {ATTRIBUTES = (Public, ); }; }; 11 | C7BB12701DF57DDA00228A8D /* Mountain.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB126B1DF57DDA00228A8D /* Mountain.swift */; }; 12 | C7BB12711DF57DDA00228A8D /* MountainLayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB126C1DF57DDA00228A8D /* MountainLayer.swift */; }; 13 | C7BB12721DF57DDA00228A8D /* MountainLayerHaving.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB126D1DF57DDA00228A8D /* MountainLayerHaving.swift */; }; 14 | C7BB12731DF57DDA00228A8D /* UIApplicationExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB126E1DF57DDA00228A8D /* UIApplicationExtension.swift */; }; 15 | C7BB12741DF57DDA00228A8D /* UIViewExtension.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB126F1DF57DDA00228A8D /* UIViewExtension.swift */; }; 16 | C7BB12761DF57DE200228A8D /* Climbing.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB12751DF57DE200228A8D /* Climbing.swift */; }; 17 | C7BB12BA1DF59A3B00228A8D /* Information.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB12B91DF59A3B00228A8D /* Information.swift */; }; 18 | /* End PBXBuildFile section */ 19 | 20 | /* Begin PBXFileReference section */ 21 | C7BB12601DF57D8600228A8D /* Mountain.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Mountain.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 22 | C7BB12631DF57D8600228A8D /* Mountain.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Mountain.h; sourceTree = ""; }; 23 | C7BB12641DF57D8600228A8D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 24 | C7BB126B1DF57DDA00228A8D /* Mountain.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Mountain.swift; sourceTree = ""; }; 25 | C7BB126C1DF57DDA00228A8D /* MountainLayer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MountainLayer.swift; sourceTree = ""; }; 26 | C7BB126D1DF57DDA00228A8D /* MountainLayerHaving.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MountainLayerHaving.swift; sourceTree = ""; }; 27 | C7BB126E1DF57DDA00228A8D /* UIApplicationExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIApplicationExtension.swift; sourceTree = ""; }; 28 | C7BB126F1DF57DDA00228A8D /* UIViewExtension.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = UIViewExtension.swift; sourceTree = ""; }; 29 | C7BB12751DF57DE200228A8D /* Climbing.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Climbing.swift; sourceTree = ""; }; 30 | C7BB12B91DF59A3B00228A8D /* Information.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Information.swift; sourceTree = ""; }; 31 | /* End PBXFileReference section */ 32 | 33 | /* Begin PBXFrameworksBuildPhase section */ 34 | C7BB125C1DF57D8600228A8D /* Frameworks */ = { 35 | isa = PBXFrameworksBuildPhase; 36 | buildActionMask = 2147483647; 37 | files = ( 38 | ); 39 | runOnlyForDeploymentPostprocessing = 0; 40 | }; 41 | /* End PBXFrameworksBuildPhase section */ 42 | 43 | /* Begin PBXGroup section */ 44 | C7BB12561DF57D8600228A8D = { 45 | isa = PBXGroup; 46 | children = ( 47 | C7BB12621DF57D8600228A8D /* Mountain */, 48 | C7BB12611DF57D8600228A8D /* Products */, 49 | ); 50 | sourceTree = ""; 51 | }; 52 | C7BB12611DF57D8600228A8D /* Products */ = { 53 | isa = PBXGroup; 54 | children = ( 55 | C7BB12601DF57D8600228A8D /* Mountain.framework */, 56 | ); 57 | name = Products; 58 | sourceTree = ""; 59 | }; 60 | C7BB12621DF57D8600228A8D /* Mountain */ = { 61 | isa = PBXGroup; 62 | children = ( 63 | C7BB12751DF57DE200228A8D /* Climbing.swift */, 64 | C7BB12631DF57D8600228A8D /* Mountain.h */, 65 | C7BB12641DF57D8600228A8D /* Info.plist */, 66 | C7BB12B91DF59A3B00228A8D /* Information.swift */, 67 | C7BB126B1DF57DDA00228A8D /* Mountain.swift */, 68 | C7BB126C1DF57DDA00228A8D /* MountainLayer.swift */, 69 | C7BB126D1DF57DDA00228A8D /* MountainLayerHaving.swift */, 70 | C7BB126E1DF57DDA00228A8D /* UIApplicationExtension.swift */, 71 | C7BB126F1DF57DDA00228A8D /* UIViewExtension.swift */, 72 | ); 73 | path = Mountain; 74 | sourceTree = ""; 75 | }; 76 | /* End PBXGroup section */ 77 | 78 | /* Begin PBXHeadersBuildPhase section */ 79 | C7BB125D1DF57D8600228A8D /* Headers */ = { 80 | isa = PBXHeadersBuildPhase; 81 | buildActionMask = 2147483647; 82 | files = ( 83 | C7BB12651DF57D8600228A8D /* Mountain.h in Headers */, 84 | ); 85 | runOnlyForDeploymentPostprocessing = 0; 86 | }; 87 | /* End PBXHeadersBuildPhase section */ 88 | 89 | /* Begin PBXNativeTarget section */ 90 | C7BB125F1DF57D8600228A8D /* Mountain */ = { 91 | isa = PBXNativeTarget; 92 | buildConfigurationList = C7BB12681DF57D8600228A8D /* Build configuration list for PBXNativeTarget "Mountain" */; 93 | buildPhases = ( 94 | C7BB125B1DF57D8600228A8D /* Sources */, 95 | C7BB125C1DF57D8600228A8D /* Frameworks */, 96 | C7BB125D1DF57D8600228A8D /* Headers */, 97 | C7BB125E1DF57D8600228A8D /* Resources */, 98 | ); 99 | buildRules = ( 100 | ); 101 | dependencies = ( 102 | ); 103 | name = Mountain; 104 | productName = Mountains; 105 | productReference = C7BB12601DF57D8600228A8D /* Mountain.framework */; 106 | productType = "com.apple.product-type.framework"; 107 | }; 108 | /* End PBXNativeTarget section */ 109 | 110 | /* Begin PBXProject section */ 111 | C7BB12571DF57D8600228A8D /* Project object */ = { 112 | isa = PBXProject; 113 | attributes = { 114 | LastUpgradeCheck = 1000; 115 | ORGANIZATIONNAME = "Kyohei Ito"; 116 | TargetAttributes = { 117 | C7BB125F1DF57D8600228A8D = { 118 | CreatedOnToolsVersion = 8.1; 119 | DevelopmentTeam = MX36A76L68; 120 | LastSwiftMigration = 1000; 121 | ProvisioningStyle = Automatic; 122 | }; 123 | }; 124 | }; 125 | buildConfigurationList = C7BB125A1DF57D8600228A8D /* Build configuration list for PBXProject "Mountain" */; 126 | compatibilityVersion = "Xcode 3.2"; 127 | developmentRegion = English; 128 | hasScannedForEncodings = 0; 129 | knownRegions = ( 130 | en, 131 | ); 132 | mainGroup = C7BB12561DF57D8600228A8D; 133 | productRefGroup = C7BB12611DF57D8600228A8D /* Products */; 134 | projectDirPath = ""; 135 | projectRoot = ""; 136 | targets = ( 137 | C7BB125F1DF57D8600228A8D /* Mountain */, 138 | ); 139 | }; 140 | /* End PBXProject section */ 141 | 142 | /* Begin PBXResourcesBuildPhase section */ 143 | C7BB125E1DF57D8600228A8D /* Resources */ = { 144 | isa = PBXResourcesBuildPhase; 145 | buildActionMask = 2147483647; 146 | files = ( 147 | ); 148 | runOnlyForDeploymentPostprocessing = 0; 149 | }; 150 | /* End PBXResourcesBuildPhase section */ 151 | 152 | /* Begin PBXSourcesBuildPhase section */ 153 | C7BB125B1DF57D8600228A8D /* Sources */ = { 154 | isa = PBXSourcesBuildPhase; 155 | buildActionMask = 2147483647; 156 | files = ( 157 | C7BB12761DF57DE200228A8D /* Climbing.swift in Sources */, 158 | C7BB12BA1DF59A3B00228A8D /* Information.swift in Sources */, 159 | C7BB12741DF57DDA00228A8D /* UIViewExtension.swift in Sources */, 160 | C7BB12711DF57DDA00228A8D /* MountainLayer.swift in Sources */, 161 | C7BB12701DF57DDA00228A8D /* Mountain.swift in Sources */, 162 | C7BB12731DF57DDA00228A8D /* UIApplicationExtension.swift in Sources */, 163 | C7BB12721DF57DDA00228A8D /* MountainLayerHaving.swift in Sources */, 164 | ); 165 | runOnlyForDeploymentPostprocessing = 0; 166 | }; 167 | /* End PBXSourcesBuildPhase section */ 168 | 169 | /* Begin XCBuildConfiguration section */ 170 | C7BB12661DF57D8600228A8D /* Debug */ = { 171 | isa = XCBuildConfiguration; 172 | buildSettings = { 173 | ALWAYS_SEARCH_USER_PATHS = NO; 174 | CLANG_ANALYZER_NONNULL = YES; 175 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 176 | CLANG_CXX_LIBRARY = "libc++"; 177 | CLANG_ENABLE_MODULES = YES; 178 | CLANG_ENABLE_OBJC_ARC = YES; 179 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 180 | CLANG_WARN_BOOL_CONVERSION = YES; 181 | CLANG_WARN_COMMA = YES; 182 | CLANG_WARN_CONSTANT_CONVERSION = YES; 183 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 184 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 185 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 186 | CLANG_WARN_EMPTY_BODY = YES; 187 | CLANG_WARN_ENUM_CONVERSION = YES; 188 | CLANG_WARN_INFINITE_RECURSION = YES; 189 | CLANG_WARN_INT_CONVERSION = YES; 190 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 191 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 192 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 193 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 194 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 195 | CLANG_WARN_STRICT_PROTOTYPES = YES; 196 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 197 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 198 | CLANG_WARN_UNREACHABLE_CODE = YES; 199 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 200 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 201 | COPY_PHASE_STRIP = NO; 202 | CURRENT_PROJECT_VERSION = 1; 203 | DEBUG_INFORMATION_FORMAT = dwarf; 204 | ENABLE_STRICT_OBJC_MSGSEND = YES; 205 | ENABLE_TESTABILITY = YES; 206 | GCC_C_LANGUAGE_STANDARD = gnu99; 207 | GCC_DYNAMIC_NO_PIC = NO; 208 | GCC_NO_COMMON_BLOCKS = YES; 209 | GCC_OPTIMIZATION_LEVEL = 0; 210 | GCC_PREPROCESSOR_DEFINITIONS = ( 211 | "DEBUG=1", 212 | "$(inherited)", 213 | ); 214 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 215 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 216 | GCC_WARN_UNDECLARED_SELECTOR = YES; 217 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 218 | GCC_WARN_UNUSED_FUNCTION = YES; 219 | GCC_WARN_UNUSED_VARIABLE = YES; 220 | INFOPLIST_FILE = ""; 221 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 222 | MTL_ENABLE_DEBUG_INFO = YES; 223 | ONLY_ACTIVE_ARCH = YES; 224 | SDKROOT = iphoneos; 225 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 226 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 227 | TARGETED_DEVICE_FAMILY = "1,2"; 228 | VERSIONING_SYSTEM = "apple-generic"; 229 | VERSION_INFO_PREFIX = ""; 230 | }; 231 | name = Debug; 232 | }; 233 | C7BB12671DF57D8600228A8D /* Release */ = { 234 | isa = XCBuildConfiguration; 235 | buildSettings = { 236 | ALWAYS_SEARCH_USER_PATHS = NO; 237 | CLANG_ANALYZER_NONNULL = YES; 238 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 239 | CLANG_CXX_LIBRARY = "libc++"; 240 | CLANG_ENABLE_MODULES = YES; 241 | CLANG_ENABLE_OBJC_ARC = YES; 242 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 243 | CLANG_WARN_BOOL_CONVERSION = YES; 244 | CLANG_WARN_COMMA = YES; 245 | CLANG_WARN_CONSTANT_CONVERSION = YES; 246 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 247 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 248 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 249 | CLANG_WARN_EMPTY_BODY = YES; 250 | CLANG_WARN_ENUM_CONVERSION = YES; 251 | CLANG_WARN_INFINITE_RECURSION = YES; 252 | CLANG_WARN_INT_CONVERSION = YES; 253 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 254 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 255 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 256 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 257 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 258 | CLANG_WARN_STRICT_PROTOTYPES = YES; 259 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 260 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 261 | CLANG_WARN_UNREACHABLE_CODE = YES; 262 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 263 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 264 | COPY_PHASE_STRIP = NO; 265 | CURRENT_PROJECT_VERSION = 1; 266 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 267 | ENABLE_NS_ASSERTIONS = NO; 268 | ENABLE_STRICT_OBJC_MSGSEND = YES; 269 | GCC_C_LANGUAGE_STANDARD = gnu99; 270 | GCC_NO_COMMON_BLOCKS = YES; 271 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 272 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 273 | GCC_WARN_UNDECLARED_SELECTOR = YES; 274 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 275 | GCC_WARN_UNUSED_FUNCTION = YES; 276 | GCC_WARN_UNUSED_VARIABLE = YES; 277 | INFOPLIST_FILE = ""; 278 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 279 | MTL_ENABLE_DEBUG_INFO = NO; 280 | SDKROOT = iphoneos; 281 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 282 | TARGETED_DEVICE_FAMILY = "1,2"; 283 | VALIDATE_PRODUCT = YES; 284 | VERSIONING_SYSTEM = "apple-generic"; 285 | VERSION_INFO_PREFIX = ""; 286 | }; 287 | name = Release; 288 | }; 289 | C7BB12691DF57D8600228A8D /* Debug */ = { 290 | isa = XCBuildConfiguration; 291 | buildSettings = { 292 | CLANG_ENABLE_MODULES = YES; 293 | CODE_SIGN_IDENTITY = ""; 294 | DEFINES_MODULE = YES; 295 | DEVELOPMENT_TEAM = MX36A76L68; 296 | DYLIB_COMPATIBILITY_VERSION = 1; 297 | DYLIB_CURRENT_VERSION = 1; 298 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 299 | INFOPLIST_FILE = Mountain/Info.plist; 300 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 301 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 302 | PRODUCT_BUNDLE_IDENTIFIER = com.kyoheiito.Mountain; 303 | PRODUCT_NAME = "$(TARGET_NAME)"; 304 | SKIP_INSTALL = YES; 305 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 306 | SWIFT_VERSION = 4.2; 307 | }; 308 | name = Debug; 309 | }; 310 | C7BB126A1DF57D8600228A8D /* Release */ = { 311 | isa = XCBuildConfiguration; 312 | buildSettings = { 313 | CLANG_ENABLE_MODULES = YES; 314 | CODE_SIGN_IDENTITY = ""; 315 | DEFINES_MODULE = YES; 316 | DEVELOPMENT_TEAM = MX36A76L68; 317 | DYLIB_COMPATIBILITY_VERSION = 1; 318 | DYLIB_CURRENT_VERSION = 1; 319 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 320 | INFOPLIST_FILE = Mountain/Info.plist; 321 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 322 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 323 | PRODUCT_BUNDLE_IDENTIFIER = com.kyoheiito.Mountain; 324 | PRODUCT_NAME = "$(TARGET_NAME)"; 325 | SKIP_INSTALL = YES; 326 | SWIFT_VERSION = 4.2; 327 | }; 328 | name = Release; 329 | }; 330 | /* End XCBuildConfiguration section */ 331 | 332 | /* Begin XCConfigurationList section */ 333 | C7BB125A1DF57D8600228A8D /* Build configuration list for PBXProject "Mountain" */ = { 334 | isa = XCConfigurationList; 335 | buildConfigurations = ( 336 | C7BB12661DF57D8600228A8D /* Debug */, 337 | C7BB12671DF57D8600228A8D /* Release */, 338 | ); 339 | defaultConfigurationIsVisible = 0; 340 | defaultConfigurationName = Release; 341 | }; 342 | C7BB12681DF57D8600228A8D /* Build configuration list for PBXNativeTarget "Mountain" */ = { 343 | isa = XCConfigurationList; 344 | buildConfigurations = ( 345 | C7BB12691DF57D8600228A8D /* Debug */, 346 | C7BB126A1DF57D8600228A8D /* Release */, 347 | ); 348 | defaultConfigurationIsVisible = 0; 349 | defaultConfigurationName = Release; 350 | }; 351 | /* End XCConfigurationList section */ 352 | }; 353 | rootObject = C7BB12571DF57D8600228A8D /* Project object */; 354 | } 355 | -------------------------------------------------------------------------------- /Mountain.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Mountain.xcodeproj/xcshareddata/xcschemes/Mountain.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 | -------------------------------------------------------------------------------- /Mountain/Climbing.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Climbing.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/04. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | public enum ClimbingSituation { 10 | case begin(info: Information) 11 | case on(progress: CGFloat, curve: CGFloat) 12 | case cancelled, finished 13 | } 14 | 15 | public protocol ClimbDownable { 16 | func climbDown() 17 | } 18 | 19 | public protocol Climbingable: ClimbDownable { 20 | @discardableResult 21 | func climb() -> Climber 22 | } 23 | 24 | public protocol ClimbFinishable { 25 | func finish(_ handler: @escaping (ClimbingSituation) -> Void) 26 | } 27 | 28 | public protocol Climber: ClimbFinishable { 29 | @discardableResult 30 | func situation(_ handler: @escaping (ClimbingSituation) -> Void) -> ClimbFinishable 31 | func filter(_ handler: @escaping (CGFloat, CGFloat) -> Bool) -> Self 32 | func map(_ handler: @escaping (CGFloat) -> CGFloat) -> Self 33 | } 34 | -------------------------------------------------------------------------------- /Mountain/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 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /Mountain/Information.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Information.swift 3 | // Mountain 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | public struct Information { 10 | public static let `default` = Information(type: "CAAnimation", animation: CABasicAnimation()) 11 | 12 | public let type: String 13 | public let delay: CFTimeInterval 14 | public let duration: CFTimeInterval 15 | public let reverse: Bool 16 | public let repeatCount: Float 17 | public let function: CAMediaTimingFunction? 18 | 19 | init(type: String, animation: CABasicAnimation) { 20 | self.type = type 21 | self.delay = animation.beginTime 22 | self.duration = animation.duration 23 | self.reverse = animation.autoreverses 24 | self.repeatCount = animation.repeatCount 25 | self.function = animation.timingFunction 26 | } 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Mountain/Mountain.h: -------------------------------------------------------------------------------- 1 | // 2 | // Mountain.h 3 | // Mountain 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for Mountain. 12 | FOUNDATION_EXPORT double MountainVersionNumber; 13 | 14 | //! Project version string for Mountain. 15 | FOUNDATION_EXPORT const unsigned char MountainVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /Mountain/Mountain.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Mountain.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/04. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | public class Mountain: ClimbDownable { 12 | private class View: UIView, MountainLayerHaving { 13 | override class var layerClass: AnyClass { 14 | return MountainLayer.self 15 | } 16 | var mountainLayer: MountainLayer { 17 | return layer as! MountainLayer 18 | } 19 | } 20 | 21 | deinit { 22 | climbDown() 23 | } 24 | 25 | private let view = View() 26 | 27 | public init() { 28 | view.isHidden = true 29 | } 30 | 31 | public func climb(retainSelf: Bool = false) -> Climber { 32 | let layer = view.mountainLayer 33 | layer.prepareForClimbing(of: retainSelf ? self : nil) 34 | return view.climb() 35 | } 36 | 37 | public func climbDown() { 38 | view.climbDown() 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Mountain/MountainLayer.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MountainLayer.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/11/30. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private protocol Easing { 12 | var progress: CGFloat { get } 13 | var curve: CGFloat { get } 14 | } 15 | 16 | public protocol MountainLayerDelegate: CALayerDelegate { 17 | func climbingSituationDidChange(_ layer: MountainLayer, situation: ClimbingSituation) 18 | } 19 | 20 | public extension MountainLayerDelegate { 21 | func climbingSituationDidChange(_ layer: MountainLayer, situation: ClimbingSituation) { 22 | // Do nothing 23 | } 24 | } 25 | 26 | public class MountainLayer: CALayer, Easing { 27 | fileprivate struct Ease: Easing { 28 | let curve: CGFloat 29 | let progress: CGFloat 30 | } 31 | 32 | private static let progressKey = "progress" 33 | private static let curveKey = "curve" 34 | fileprivate struct Distance { 35 | let progressKey = MountainLayer.progressKey 36 | let curveKey = MountainLayer.curveKey 37 | let from = Ease(curve: 0, progress: 0) 38 | let to = Ease(curve: 1, progress: 1) 39 | } 40 | 41 | override public class func needsDisplay(forKey key: String) -> Bool { 42 | if key == progressKey || key == curveKey { 43 | return true 44 | } 45 | return super.needsDisplay(forKey: key) 46 | } 47 | 48 | fileprivate let distance = Distance() 49 | 50 | fileprivate var information: Information? 51 | fileprivate var capturedMountain: Mountain? 52 | fileprivate var situationHandler: ((ClimbingSituation) -> Void)? { 53 | willSet { 54 | if let info = information, let handler = newValue { 55 | handler(.begin(info: info)) 56 | } 57 | } 58 | } 59 | fileprivate var filterHandler: ((CGFloat, CGFloat) -> Bool)? 60 | fileprivate var mapHandler: ((CGFloat) -> CGFloat)? 61 | fileprivate var finishHandler: ((ClimbingSituation) -> Void)? 62 | 63 | fileprivate var isClimbing = false 64 | fileprivate var isClimbingFinish: Bool { 65 | if isClimbing, let layer = presentation() { 66 | return layer.progress == distance.to.progress 67 | } else { 68 | return false 69 | } 70 | } 71 | fileprivate var isProgressing: Bool { 72 | return isClimbing == true && isClimbingFinish == false 73 | } 74 | 75 | fileprivate weak var workingSuperlayer: CALayer? 76 | fileprivate weak var animationDelegate: CAAnimationDelegate? 77 | fileprivate var mountainDelegate: MountainLayerDelegate? { 78 | return delegate as? MountainLayerDelegate 79 | } 80 | 81 | @NSManaged fileprivate var progress: CGFloat 82 | @NSManaged fileprivate var curve: CGFloat 83 | 84 | func prepareForClimbing(of mountain: Mountain? = nil) { 85 | capturedMountain = mountain 86 | if superlayer == nil, let view = UIApplication.visibleViewController?.view { 87 | view.layer.addSublayer(self) 88 | workingSuperlayer = view.layer 89 | } 90 | } 91 | 92 | fileprivate func setCurrentEase(_ ease: Easing) { 93 | if delegate != nil { 94 | curve = ease.curve 95 | progress = ease.progress 96 | } 97 | } 98 | 99 | fileprivate func resetForClimbing() { 100 | setCurrentEase(distance.from) 101 | removeSituationHandler() 102 | 103 | if workingSuperlayer != nil { 104 | removeFromSuperlayer() 105 | } 106 | } 107 | 108 | private func removeSituationHandler() { 109 | information = nil 110 | situationHandler = nil 111 | filterHandler = nil 112 | mapHandler = nil 113 | finishHandler = nil 114 | capturedMountain = nil 115 | } 116 | } 117 | 118 | // MARK: Situation operation 119 | extension MountainLayer { 120 | fileprivate func changeClimbingSituation(_ situation: ClimbingSituation) { 121 | switch situation { 122 | case .begin: 123 | break 124 | case .on: 125 | situationHandler?(situation) 126 | case .cancelled, .finished: 127 | finishHandler?(situation) 128 | } 129 | 130 | mountainDelegate?.climbingSituationDidChange(self, situation: situation) 131 | } 132 | 133 | fileprivate func filterSituation(progress: CGFloat, curve: CGFloat) -> Bool { 134 | return filterHandler?(progress, curve) != false 135 | } 136 | 137 | fileprivate func mapSituation(_ curve: CGFloat) -> CGFloat { 138 | return mapHandler?(curve) ?? curve 139 | } 140 | } 141 | 142 | // MARK: Layer life cycle 143 | extension MountainLayer { 144 | override public func removeFromSuperlayer() { 145 | setCurrentEase(distance.from) 146 | 147 | super.removeFromSuperlayer() 148 | workingSuperlayer = nil 149 | resetForClimbing() 150 | } 151 | 152 | override public func display() { 153 | super.display() 154 | 155 | guard isClimbing else { 156 | return setCurrentEase(distance.from) 157 | } 158 | 159 | if let easing: Easing = presentation(), easing.progress > 0 && filterSituation(progress: easing.progress, curve: easing.curve) != false { 160 | changeClimbingSituation(.on(progress: easing.progress, curve: mapSituation(easing.curve))) 161 | } 162 | } 163 | 164 | override public func action(forKey event: String) -> CAAction? { 165 | if event == distance.progressKey || event == distance.curveKey { 166 | if event == distance.progressKey { 167 | isClimbing = false 168 | } 169 | 170 | if let action = super.action(forKey: "opacity") { 171 | if event == distance.curveKey, let action = action as? CABasicAnimation { 172 | let info = Information(type: "\(type(of: action))", animation: action) 173 | information = info 174 | changeClimbingSituation(.begin(info: info)) 175 | 176 | action.keyPath = event 177 | action.fromValue = distance.from.curve 178 | action.toValue = distance.to.curve 179 | return action 180 | } else if event == distance.progressKey, let action = action as? CAAnimation { 181 | isClimbing = true 182 | 183 | let anim = CABasicAnimation() 184 | anim.fromValue = distance.from.progress 185 | anim.toValue = distance.to.progress 186 | anim.beginTime = CACurrentMediaTime() + action.beginTime 187 | anim.duration = action.duration 188 | anim.speed = action.speed 189 | anim.timeOffset = action.timeOffset 190 | anim.repeatCount = action.repeatCount 191 | anim.repeatDuration = action.repeatDuration 192 | anim.autoreverses = action.autoreverses 193 | anim.fillMode = action.fillMode 194 | anim.timingFunction = CAMediaTimingFunction(name: .linear) 195 | 196 | animationDelegate = action.delegate 197 | anim.delegate = self 198 | return anim 199 | } 200 | } 201 | } 202 | 203 | return super.action(forKey: event) 204 | } 205 | } 206 | 207 | // MARK: Climbingable 208 | extension MountainLayer: Climbingable { 209 | public func climb() -> Climber { 210 | if isProgressing { 211 | UIView.performWithoutAnimation { 212 | setCurrentEase(distance.from) 213 | } 214 | } 215 | 216 | setCurrentEase(distance.to) 217 | return self 218 | } 219 | 220 | public func climbDown() { 221 | removeAnimation(forKey: distance.progressKey) 222 | removeAnimation(forKey: distance.curveKey) 223 | } 224 | } 225 | 226 | // MARK: Climber 227 | extension MountainLayer: Climber { 228 | @discardableResult 229 | public func situation(_ handler: @escaping (ClimbingSituation) -> Void) -> ClimbFinishable { 230 | situationHandler = handler 231 | return self 232 | } 233 | 234 | public func filter(_ handler: @escaping (CGFloat, CGFloat) -> Bool) -> Self { 235 | filterHandler = handler 236 | return self 237 | } 238 | 239 | public func map(_ handler: @escaping (CGFloat) -> CGFloat) -> Self { 240 | mapHandler = handler 241 | return self 242 | } 243 | 244 | public func finish(_ handler: @escaping (ClimbingSituation) -> Void) { 245 | finishHandler = handler 246 | } 247 | } 248 | 249 | // MARK: CAAnimationDelegate 250 | extension MountainLayer: CAAnimationDelegate { 251 | public func animationDidStart(_ anim: CAAnimation) { 252 | animationDelegate?.animationDidStart?(anim) 253 | } 254 | 255 | public func animationDidStop(_ anim: CAAnimation, finished flag: Bool) { 256 | if flag { 257 | changeClimbingSituation(.finished) 258 | } else { 259 | changeClimbingSituation(.cancelled) 260 | } 261 | 262 | if isClimbingFinish { 263 | resetForClimbing() 264 | } 265 | 266 | animationDelegate?.animationDidStop?(anim, finished: flag) 267 | } 268 | } 269 | -------------------------------------------------------------------------------- /Mountain/MountainLayerHaving.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MountainLayerHaving.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | public protocol MountainLayerHaving: Climbingable { 10 | var mountainLayer: MountainLayer { get } 11 | } 12 | 13 | public extension MountainLayerHaving { 14 | @discardableResult 15 | public func climb() -> Climber { 16 | return mountainLayer.climb() 17 | } 18 | 19 | public func climbDown() { 20 | mountainLayer.climbDown() 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Mountain/UIApplicationExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIApplicationExtension.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/04. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | extension UIApplication { 10 | class var visibleViewController: UIViewController? { 11 | var presentedViewController = UIApplication.shared.delegate?.window??.rootViewController 12 | while let presentedVC = presentedViewController?.presentedViewController { 13 | presentedViewController = presentedVC 14 | } 15 | 16 | if let navigationController = presentedViewController as? UINavigationController { 17 | return navigationController.visibleViewController ?? presentedViewController 18 | } else { 19 | return presentedViewController 20 | } 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Mountain/UIViewExtension.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIViewExtension.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | extension UIView { 10 | @discardableResult 11 | open class func animate(withDuration duration: TimeInterval, delay: TimeInterval = 0, options: UIView.AnimationOptions = [], retain: Bool = true, animations: @escaping () -> Void = {}, situation: @escaping (ClimbingSituation) -> Void, completion: ((Bool) -> Void)? = nil) -> ClimbDownable? { 12 | let mountain = Mountain() 13 | 14 | UIView.animate(withDuration: duration, delay: delay, options: options, animations: { 15 | mountain.climb(retainSelf: retain).situation(situation) 16 | animations() 17 | }, completion: completion) 18 | 19 | return mountain 20 | } 21 | 22 | @discardableResult 23 | open class func animate(withDuration duration: TimeInterval, delay: TimeInterval = 0, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIView.AnimationOptions = [], retain: Bool = true, animations: @escaping () -> Void = {}, situation: @escaping (ClimbingSituation) -> Void, completion: ((Bool) -> Void)? = nil) -> ClimbDownable? { 24 | let mountain = Mountain() 25 | 26 | UIView.animate(withDuration: duration, delay: delay, usingSpringWithDamping: dampingRatio, initialSpringVelocity: velocity, options: options, animations: { 27 | mountain.climb(retainSelf: retain).situation(situation) 28 | animations() 29 | }, completion: completion) 30 | 31 | return mountain 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /MountainView.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "MountainView" 3 | s.summary = "The animation curve looks like Mountain View." 4 | s.homepage = "https://github.com/KyoheiG3/MountainView" 5 | s.version = "0.2.0" 6 | s.license = { :type => "MIT", :file => "LICENSE" } 7 | s.author = { "Kyohei Ito" => "je.suis.kyohei@gmail.com" } 8 | s.swift_version = '4.2' 9 | s.ios.deployment_target = '9.0' 10 | s.tvos.deployment_target = '9.0' 11 | s.source = { :git => "https://github.com/KyoheiG3/MountainView.git", :tag => s.version.to_s } 12 | s.source_files = "MountainView/**/*.{h,swift}" 13 | s.requires_arc = true 14 | s.frameworks = "UIKit" 15 | s.dependency "Mountain" 16 | end 17 | -------------------------------------------------------------------------------- /MountainView.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C721ACA61F144E560098376A /* Mountain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C721ACA21F144E240098376A /* Mountain.framework */; }; 11 | C7B4278F1DF45CCD008A27BD /* MountainView.h in Headers */ = {isa = PBXBuildFile; fileRef = C7B4278D1DF45CCD008A27BD /* MountainView.h */; settings = {ATTRIBUTES = (Public, ); }; }; 12 | C7BB129D1DF57F6C00228A8D /* MountainView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB129C1DF57F6C00228A8D /* MountainView.swift */; }; 13 | C7BB12B31DF580CD00228A8D /* CurveView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB12B21DF580CD00228A8D /* CurveView.swift */; }; 14 | C7BB12B61DF5813D00228A8D /* CrossView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB12B51DF5813D00228A8D /* CrossView.swift */; }; 15 | C7BB12B81DF5815A00228A8D /* GridView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB12B71DF5815A00228A8D /* GridView.swift */; }; 16 | C7BB12BC1DF59BCF00228A8D /* InformationView.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7BB12BB1DF59BCF00228A8D /* InformationView.swift */; }; 17 | /* End PBXBuildFile section */ 18 | 19 | /* Begin PBXContainerItemProxy section */ 20 | C721ACA11F144E240098376A /* PBXContainerItemProxy */ = { 21 | isa = PBXContainerItemProxy; 22 | containerPortal = C721AC9D1F144E240098376A /* Mountain.xcodeproj */; 23 | proxyType = 2; 24 | remoteGlobalIDString = C7BB12601DF57D8600228A8D; 25 | remoteInfo = Mountain; 26 | }; 27 | /* End PBXContainerItemProxy section */ 28 | 29 | /* Begin PBXFileReference section */ 30 | C721AC9D1F144E240098376A /* Mountain.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; path = Mountain.xcodeproj; sourceTree = ""; }; 31 | C7B4278A1DF45CCD008A27BD /* MountainView.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = MountainView.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 32 | C7B4278D1DF45CCD008A27BD /* MountainView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MountainView.h; sourceTree = ""; }; 33 | C7B4278E1DF45CCD008A27BD /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 34 | C7BB129C1DF57F6C00228A8D /* MountainView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MountainView.swift; sourceTree = ""; }; 35 | C7BB12B21DF580CD00228A8D /* CurveView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CurveView.swift; sourceTree = ""; }; 36 | C7BB12B51DF5813D00228A8D /* CrossView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CrossView.swift; sourceTree = ""; }; 37 | C7BB12B71DF5815A00228A8D /* GridView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GridView.swift; sourceTree = ""; }; 38 | C7BB12BB1DF59BCF00228A8D /* InformationView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InformationView.swift; sourceTree = ""; }; 39 | /* End PBXFileReference section */ 40 | 41 | /* Begin PBXFrameworksBuildPhase section */ 42 | C7B427861DF45CCD008A27BD /* Frameworks */ = { 43 | isa = PBXFrameworksBuildPhase; 44 | buildActionMask = 2147483647; 45 | files = ( 46 | C721ACA61F144E560098376A /* Mountain.framework in Frameworks */, 47 | ); 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXFrameworksBuildPhase section */ 51 | 52 | /* Begin PBXGroup section */ 53 | C721AC9E1F144E240098376A /* Products */ = { 54 | isa = PBXGroup; 55 | children = ( 56 | C721ACA21F144E240098376A /* Mountain.framework */, 57 | ); 58 | name = Products; 59 | sourceTree = ""; 60 | }; 61 | C7B427801DF45CCD008A27BD = { 62 | isa = PBXGroup; 63 | children = ( 64 | C721AC9D1F144E240098376A /* Mountain.xcodeproj */, 65 | C7B4278C1DF45CCD008A27BD /* MountainView */, 66 | C7B4278B1DF45CCD008A27BD /* Products */, 67 | ); 68 | sourceTree = ""; 69 | }; 70 | C7B4278B1DF45CCD008A27BD /* Products */ = { 71 | isa = PBXGroup; 72 | children = ( 73 | C7B4278A1DF45CCD008A27BD /* MountainView.framework */, 74 | ); 75 | name = Products; 76 | sourceTree = ""; 77 | }; 78 | C7B4278C1DF45CCD008A27BD /* MountainView */ = { 79 | isa = PBXGroup; 80 | children = ( 81 | C7BB12B51DF5813D00228A8D /* CrossView.swift */, 82 | C7BB12B21DF580CD00228A8D /* CurveView.swift */, 83 | C7BB12B71DF5815A00228A8D /* GridView.swift */, 84 | C7B4278E1DF45CCD008A27BD /* Info.plist */, 85 | C7BB12BB1DF59BCF00228A8D /* InformationView.swift */, 86 | C7B4278D1DF45CCD008A27BD /* MountainView.h */, 87 | C7BB129C1DF57F6C00228A8D /* MountainView.swift */, 88 | ); 89 | path = MountainView; 90 | sourceTree = ""; 91 | }; 92 | /* End PBXGroup section */ 93 | 94 | /* Begin PBXHeadersBuildPhase section */ 95 | C7B427871DF45CCD008A27BD /* Headers */ = { 96 | isa = PBXHeadersBuildPhase; 97 | buildActionMask = 2147483647; 98 | files = ( 99 | C7B4278F1DF45CCD008A27BD /* MountainView.h in Headers */, 100 | ); 101 | runOnlyForDeploymentPostprocessing = 0; 102 | }; 103 | /* End PBXHeadersBuildPhase section */ 104 | 105 | /* Begin PBXNativeTarget section */ 106 | C7B427891DF45CCD008A27BD /* MountainView */ = { 107 | isa = PBXNativeTarget; 108 | buildConfigurationList = C7B427921DF45CCD008A27BD /* Build configuration list for PBXNativeTarget "MountainView" */; 109 | buildPhases = ( 110 | C7B427851DF45CCD008A27BD /* Sources */, 111 | C7B427861DF45CCD008A27BD /* Frameworks */, 112 | C7B427871DF45CCD008A27BD /* Headers */, 113 | C7B427881DF45CCD008A27BD /* Resources */, 114 | ); 115 | buildRules = ( 116 | ); 117 | dependencies = ( 118 | ); 119 | name = MountainView; 120 | productName = MountainsView; 121 | productReference = C7B4278A1DF45CCD008A27BD /* MountainView.framework */; 122 | productType = "com.apple.product-type.framework"; 123 | }; 124 | /* End PBXNativeTarget section */ 125 | 126 | /* Begin PBXProject section */ 127 | C7B427811DF45CCD008A27BD /* Project object */ = { 128 | isa = PBXProject; 129 | attributes = { 130 | LastUpgradeCheck = 1000; 131 | ORGANIZATIONNAME = "Kyohei Ito"; 132 | TargetAttributes = { 133 | C7B427891DF45CCD008A27BD = { 134 | CreatedOnToolsVersion = 8.1; 135 | DevelopmentTeam = MX36A76L68; 136 | LastSwiftMigration = 1000; 137 | ProvisioningStyle = Automatic; 138 | }; 139 | }; 140 | }; 141 | buildConfigurationList = C7B427841DF45CCD008A27BD /* Build configuration list for PBXProject "MountainView" */; 142 | compatibilityVersion = "Xcode 3.2"; 143 | developmentRegion = English; 144 | hasScannedForEncodings = 0; 145 | knownRegions = ( 146 | en, 147 | ); 148 | mainGroup = C7B427801DF45CCD008A27BD; 149 | productRefGroup = C7B4278B1DF45CCD008A27BD /* Products */; 150 | projectDirPath = ""; 151 | projectReferences = ( 152 | { 153 | ProductGroup = C721AC9E1F144E240098376A /* Products */; 154 | ProjectRef = C721AC9D1F144E240098376A /* Mountain.xcodeproj */; 155 | }, 156 | ); 157 | projectRoot = ""; 158 | targets = ( 159 | C7B427891DF45CCD008A27BD /* MountainView */, 160 | ); 161 | }; 162 | /* End PBXProject section */ 163 | 164 | /* Begin PBXReferenceProxy section */ 165 | C721ACA21F144E240098376A /* Mountain.framework */ = { 166 | isa = PBXReferenceProxy; 167 | fileType = wrapper.framework; 168 | path = Mountain.framework; 169 | remoteRef = C721ACA11F144E240098376A /* PBXContainerItemProxy */; 170 | sourceTree = BUILT_PRODUCTS_DIR; 171 | }; 172 | /* End PBXReferenceProxy section */ 173 | 174 | /* Begin PBXResourcesBuildPhase section */ 175 | C7B427881DF45CCD008A27BD /* Resources */ = { 176 | isa = PBXResourcesBuildPhase; 177 | buildActionMask = 2147483647; 178 | files = ( 179 | ); 180 | runOnlyForDeploymentPostprocessing = 0; 181 | }; 182 | /* End PBXResourcesBuildPhase section */ 183 | 184 | /* Begin PBXSourcesBuildPhase section */ 185 | C7B427851DF45CCD008A27BD /* Sources */ = { 186 | isa = PBXSourcesBuildPhase; 187 | buildActionMask = 2147483647; 188 | files = ( 189 | C7BB12BC1DF59BCF00228A8D /* InformationView.swift in Sources */, 190 | C7BB12B61DF5813D00228A8D /* CrossView.swift in Sources */, 191 | C7BB12B31DF580CD00228A8D /* CurveView.swift in Sources */, 192 | C7BB12B81DF5815A00228A8D /* GridView.swift in Sources */, 193 | C7BB129D1DF57F6C00228A8D /* MountainView.swift in Sources */, 194 | ); 195 | runOnlyForDeploymentPostprocessing = 0; 196 | }; 197 | /* End PBXSourcesBuildPhase section */ 198 | 199 | /* Begin XCBuildConfiguration section */ 200 | C7B427901DF45CCD008A27BD /* Debug */ = { 201 | isa = XCBuildConfiguration; 202 | buildSettings = { 203 | ALWAYS_SEARCH_USER_PATHS = NO; 204 | CLANG_ANALYZER_NONNULL = YES; 205 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 206 | CLANG_CXX_LIBRARY = "libc++"; 207 | CLANG_ENABLE_MODULES = YES; 208 | CLANG_ENABLE_OBJC_ARC = YES; 209 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 210 | CLANG_WARN_BOOL_CONVERSION = YES; 211 | CLANG_WARN_COMMA = YES; 212 | CLANG_WARN_CONSTANT_CONVERSION = YES; 213 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 214 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 215 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 216 | CLANG_WARN_EMPTY_BODY = YES; 217 | CLANG_WARN_ENUM_CONVERSION = YES; 218 | CLANG_WARN_INFINITE_RECURSION = YES; 219 | CLANG_WARN_INT_CONVERSION = YES; 220 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 221 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 222 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 223 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 224 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 225 | CLANG_WARN_STRICT_PROTOTYPES = YES; 226 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 227 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 228 | CLANG_WARN_UNREACHABLE_CODE = YES; 229 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 230 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 231 | COPY_PHASE_STRIP = NO; 232 | CURRENT_PROJECT_VERSION = 1; 233 | DEBUG_INFORMATION_FORMAT = dwarf; 234 | ENABLE_STRICT_OBJC_MSGSEND = YES; 235 | ENABLE_TESTABILITY = YES; 236 | GCC_C_LANGUAGE_STANDARD = gnu99; 237 | GCC_DYNAMIC_NO_PIC = NO; 238 | GCC_NO_COMMON_BLOCKS = YES; 239 | GCC_OPTIMIZATION_LEVEL = 0; 240 | GCC_PREPROCESSOR_DEFINITIONS = ( 241 | "DEBUG=1", 242 | "$(inherited)", 243 | ); 244 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 245 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 246 | GCC_WARN_UNDECLARED_SELECTOR = YES; 247 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 248 | GCC_WARN_UNUSED_FUNCTION = YES; 249 | GCC_WARN_UNUSED_VARIABLE = YES; 250 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 251 | MTL_ENABLE_DEBUG_INFO = YES; 252 | ONLY_ACTIVE_ARCH = YES; 253 | SDKROOT = iphoneos; 254 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 255 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 256 | TARGETED_DEVICE_FAMILY = "1,2"; 257 | VERSIONING_SYSTEM = "apple-generic"; 258 | VERSION_INFO_PREFIX = ""; 259 | }; 260 | name = Debug; 261 | }; 262 | C7B427911DF45CCD008A27BD /* Release */ = { 263 | isa = XCBuildConfiguration; 264 | buildSettings = { 265 | ALWAYS_SEARCH_USER_PATHS = NO; 266 | CLANG_ANALYZER_NONNULL = YES; 267 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 268 | CLANG_CXX_LIBRARY = "libc++"; 269 | CLANG_ENABLE_MODULES = YES; 270 | CLANG_ENABLE_OBJC_ARC = YES; 271 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 272 | CLANG_WARN_BOOL_CONVERSION = YES; 273 | CLANG_WARN_COMMA = YES; 274 | CLANG_WARN_CONSTANT_CONVERSION = YES; 275 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 276 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 277 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 278 | CLANG_WARN_EMPTY_BODY = YES; 279 | CLANG_WARN_ENUM_CONVERSION = YES; 280 | CLANG_WARN_INFINITE_RECURSION = YES; 281 | CLANG_WARN_INT_CONVERSION = YES; 282 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 283 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 284 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 285 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 286 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 287 | CLANG_WARN_STRICT_PROTOTYPES = YES; 288 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 289 | CLANG_WARN_SUSPICIOUS_MOVES = YES; 290 | CLANG_WARN_UNREACHABLE_CODE = YES; 291 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 292 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 293 | COPY_PHASE_STRIP = NO; 294 | CURRENT_PROJECT_VERSION = 1; 295 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 296 | ENABLE_NS_ASSERTIONS = NO; 297 | ENABLE_STRICT_OBJC_MSGSEND = YES; 298 | GCC_C_LANGUAGE_STANDARD = gnu99; 299 | GCC_NO_COMMON_BLOCKS = YES; 300 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 301 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 302 | GCC_WARN_UNDECLARED_SELECTOR = YES; 303 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 304 | GCC_WARN_UNUSED_FUNCTION = YES; 305 | GCC_WARN_UNUSED_VARIABLE = YES; 306 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 307 | MTL_ENABLE_DEBUG_INFO = NO; 308 | SDKROOT = iphoneos; 309 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 310 | TARGETED_DEVICE_FAMILY = "1,2"; 311 | VALIDATE_PRODUCT = YES; 312 | VERSIONING_SYSTEM = "apple-generic"; 313 | VERSION_INFO_PREFIX = ""; 314 | }; 315 | name = Release; 316 | }; 317 | C7B427931DF45CCD008A27BD /* Debug */ = { 318 | isa = XCBuildConfiguration; 319 | buildSettings = { 320 | CLANG_ENABLE_MODULES = YES; 321 | CODE_SIGN_IDENTITY = ""; 322 | DEFINES_MODULE = YES; 323 | DEVELOPMENT_TEAM = MX36A76L68; 324 | DYLIB_COMPATIBILITY_VERSION = 1; 325 | DYLIB_CURRENT_VERSION = 1; 326 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 327 | INFOPLIST_FILE = MountainView/Info.plist; 328 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 329 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 330 | PRODUCT_BUNDLE_IDENTIFIER = com.kyoheiito.MountainView; 331 | PRODUCT_NAME = "$(TARGET_NAME)"; 332 | SKIP_INSTALL = YES; 333 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 334 | SWIFT_VERSION = 4.2; 335 | }; 336 | name = Debug; 337 | }; 338 | C7B427941DF45CCD008A27BD /* Release */ = { 339 | isa = XCBuildConfiguration; 340 | buildSettings = { 341 | CLANG_ENABLE_MODULES = YES; 342 | CODE_SIGN_IDENTITY = ""; 343 | DEFINES_MODULE = YES; 344 | DEVELOPMENT_TEAM = MX36A76L68; 345 | DYLIB_COMPATIBILITY_VERSION = 1; 346 | DYLIB_CURRENT_VERSION = 1; 347 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 348 | INFOPLIST_FILE = MountainView/Info.plist; 349 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 350 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 351 | PRODUCT_BUNDLE_IDENTIFIER = com.kyoheiito.MountainView; 352 | PRODUCT_NAME = "$(TARGET_NAME)"; 353 | SKIP_INSTALL = YES; 354 | SWIFT_VERSION = 4.2; 355 | }; 356 | name = Release; 357 | }; 358 | /* End XCBuildConfiguration section */ 359 | 360 | /* Begin XCConfigurationList section */ 361 | C7B427841DF45CCD008A27BD /* Build configuration list for PBXProject "MountainView" */ = { 362 | isa = XCConfigurationList; 363 | buildConfigurations = ( 364 | C7B427901DF45CCD008A27BD /* Debug */, 365 | C7B427911DF45CCD008A27BD /* Release */, 366 | ); 367 | defaultConfigurationIsVisible = 0; 368 | defaultConfigurationName = Release; 369 | }; 370 | C7B427921DF45CCD008A27BD /* Build configuration list for PBXNativeTarget "MountainView" */ = { 371 | isa = XCConfigurationList; 372 | buildConfigurations = ( 373 | C7B427931DF45CCD008A27BD /* Debug */, 374 | C7B427941DF45CCD008A27BD /* Release */, 375 | ); 376 | defaultConfigurationIsVisible = 0; 377 | defaultConfigurationName = Release; 378 | }; 379 | /* End XCConfigurationList section */ 380 | }; 381 | rootObject = C7B427811DF45CCD008A27BD /* Project object */; 382 | } 383 | -------------------------------------------------------------------------------- /MountainView.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MountainView.xcodeproj/xcshareddata/xcschemes/MountainView.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 | -------------------------------------------------------------------------------- /MountainView/CrossView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CrossView.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CrossView: UIView { 12 | private let crossPath = UIBezierPath() 13 | var crossColor: UIColor = .black 14 | 15 | override func draw(_ rect: CGRect) { 16 | crossColor.withAlphaComponent(0.5).setStroke() 17 | crossPath.stroke() 18 | } 19 | 20 | func configureGrid() { 21 | backgroundColor = .clear 22 | 23 | crossPath.removeAllPoints() 24 | crossPath.move(to: CGPoint(x: bounds.width / 2, y: 0)) 25 | crossPath.addLine(to: CGPoint(x: bounds.width / 2, y: bounds.maxY)) 26 | crossPath.move(to: CGPoint(x: 0, y: bounds.height / 2)) 27 | crossPath.addLine(to: CGPoint(x: bounds.maxX, y: bounds.height / 2)) 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /MountainView/CurveView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // CurveView.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class CurveView: UIView { 12 | override class var layerClass: AnyClass { 13 | return CAShapeLayer.self 14 | } 15 | 16 | var shapeLayer: CAShapeLayer { 17 | return layer as! CAShapeLayer 18 | } 19 | 20 | var lineColor = UIColor.black.withAlphaComponent(0.5) 21 | var lineWidth: CGFloat = 2 22 | var lineCap = CAShapeLayerLineCap.round 23 | 24 | private var lastPoint: CGPoint? 25 | private let curvePath = UIBezierPath() 26 | 27 | func configureCurve() { 28 | shapeLayer.strokeColor = lineColor.cgColor 29 | shapeLayer.fillColor = UIColor.clear.cgColor 30 | shapeLayer.lineWidth = lineWidth 31 | shapeLayer.lineCap = lineCap 32 | 33 | lastPoint = nil 34 | curvePath.removeAllPoints() 35 | curvePath.move(to: CGPoint(x: -frame.minX, y: frame.maxY)) 36 | } 37 | 38 | func reset() { 39 | if let lastPoint = lastPoint { 40 | curvePath.addLine(to: lastPoint) 41 | shapeLayer.path = curvePath.cgPath 42 | } 43 | 44 | lastPoint = nil 45 | curvePath.removeAllPoints() 46 | curvePath.move(to: CGPoint(x: -frame.minX, y: frame.maxY)) 47 | } 48 | 49 | func move(to oritin: CGPoint) { 50 | let point = oritin - frame.origin 51 | let nextPoint: CGPoint 52 | 53 | if let lastPoint = lastPoint { 54 | nextPoint = ave(point, lastPoint) 55 | curvePath.addQuadCurve(to: nextPoint, controlPoint: lastPoint) 56 | } else { 57 | nextPoint = ave(curvePath.currentPoint, point) 58 | curvePath.addLine(to: nextPoint) 59 | } 60 | 61 | curvePath.move(to: nextPoint) 62 | shapeLayer.path = curvePath.cgPath 63 | 64 | lastPoint = point 65 | } 66 | } 67 | 68 | private extension CGPoint { 69 | static func -(lhs: CGPoint, rhs: CGPoint) -> CGPoint { 70 | return CGPoint(x: lhs.x - rhs.x, y: lhs.y - rhs.y) 71 | } 72 | } 73 | 74 | private func ave(_ lhs: CGPoint, _ rhs: CGPoint) -> CGPoint { 75 | return CGPoint(x: (lhs.x + rhs.x) / 2, y: (lhs.y + rhs.y) / 2) 76 | } 77 | -------------------------------------------------------------------------------- /MountainView/GridView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // GridView.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class GridView: UIView { 12 | private func forEachLength(_ length: CGFloat, path: UIBezierPath, each: (CGFloat) -> CGRect) { 13 | let threshold: CGFloat = 30 14 | let length = length / 2 15 | let count = max(min(ceil(length / threshold), 5), 2) 16 | 17 | stride(from: 0, to: CGFloat(2), by: 1).forEach { section in 18 | stride(from: 1, to: count, by: 1).forEach { i in 19 | let rect = each(length / count * i + length * section) 20 | path.append(UIBezierPath(rect: rect)) 21 | } 22 | } 23 | } 24 | 25 | func configureGrid() { 26 | let path = UIBezierPath(rect: bounds) 27 | forEachLength(bounds.width, path: path) { width in 28 | CGRect(x: width, y: 0, width: 1, height: bounds.height) 29 | } 30 | forEachLength(bounds.height, path: path) { height in 31 | CGRect(x: 0, y: height, width: bounds.width, height: 1) 32 | } 33 | 34 | let mask = CAShapeLayer() 35 | mask.fillRule = .evenOdd 36 | mask.path = path.cgPath 37 | layer.mask = mask 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /MountainView/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 | CFBundleVersion 20 | $(CURRENT_PROJECT_VERSION) 21 | NSPrincipalClass 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /MountainView/InformationView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // InformationView.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Mountain 11 | 12 | class InformationView: UIView { 13 | private let functionLabel = UILabel() 14 | private let parameterLabel = UILabel() 15 | private let progressLabel = UILabel() 16 | 17 | var font = UIFont.systemFont(ofSize: 8) { 18 | didSet { 19 | functionLabel.font = font 20 | parameterLabel.font = font 21 | progressLabel.font = font 22 | } 23 | } 24 | var textAlignment = NSTextAlignment.right { 25 | didSet { 26 | functionLabel.textAlignment = textAlignment 27 | parameterLabel.textAlignment = textAlignment 28 | progressLabel.textAlignment = textAlignment 29 | } 30 | } 31 | var textColor = UIColor.black.withAlphaComponent(0.5) { 32 | didSet { 33 | functionLabel.textColor = textColor 34 | parameterLabel.textColor = textColor 35 | progressLabel.textColor = textColor 36 | } 37 | } 38 | 39 | func configureLabel() { 40 | addSubview(functionLabel) 41 | addSubview(parameterLabel) 42 | addSubview(progressLabel) 43 | } 44 | 45 | func setProgress(_ progress: CGFloat) { 46 | progressLabel.text = "\(Int(progress * 100))%" 47 | 48 | UIView.performWithoutAnimation { 49 | progressLabel.sizeToFit() 50 | progressLabel.frame.origin = CGPoint(x: bounds.width - progressLabel.bounds.width - 2, y: bounds.height - progressLabel.bounds.height - parameterLabel.bounds.height - functionLabel.bounds.height) 51 | } 52 | } 53 | 54 | func setInformation(_ info: Information) { 55 | functionLabel.text = info.type 56 | parameterLabel.text = "dur:\(info.duration) del:\(info.delay)" 57 | 58 | UIView.performWithoutAnimation { 59 | parameterLabel.sizeToFit() 60 | functionLabel.sizeToFit() 61 | 62 | parameterLabel.frame.origin = CGPoint(x: bounds.width - parameterLabel.bounds.width - 2, y: bounds.height - parameterLabel.bounds.height - functionLabel.bounds.height) 63 | functionLabel.frame.origin = CGPoint(x: bounds.width - functionLabel.bounds.width - 2, y: bounds.height - functionLabel.bounds.height) 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /MountainView/MountainView.h: -------------------------------------------------------------------------------- 1 | // 2 | // MountainView.h 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/04. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | //! Project version number for MountainView. 12 | FOUNDATION_EXPORT double MountainViewVersionNumber; 13 | 14 | //! Project version string for MountainView. 15 | FOUNDATION_EXPORT const unsigned char MountainViewVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | 19 | 20 | -------------------------------------------------------------------------------- /MountainView/MountainView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MountainView.swift 3 | // MountainView 4 | // 5 | // Created by Kyohei Ito on 2016/12/05. 6 | // Copyright © 2016年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Mountain 11 | 12 | public class MountainView: UIView, MountainLayerHaving, MountainLayerDelegate { 13 | private let curveView = CurveView() 14 | private let crossView = CrossView() 15 | private let gridView = GridView() 16 | private let informationView = InformationView() 17 | public var mountainLayer: MountainLayer { 18 | return layer as! MountainLayer 19 | } 20 | 21 | var viewColor: UIColor = .black 22 | var curveLineCap: CAShapeLayerLineCap { 23 | get { return curveView.lineCap } 24 | set { curveView.lineCap = newValue } 25 | } 26 | var curveWidth: CGFloat { 27 | get { return curveView.lineWidth } 28 | set { curveView.lineWidth = newValue } 29 | } 30 | var curveColor: UIColor { 31 | get { return curveView.lineColor } 32 | set { curveView.lineColor = newValue } 33 | } 34 | 35 | override public class var layerClass: AnyClass { 36 | return MountainLayer.self 37 | } 38 | 39 | override public init(frame: CGRect) { 40 | super.init(frame: frame) 41 | configureView() 42 | resizeSubviews() 43 | } 44 | 45 | required public init?(coder aDecoder: NSCoder) { 46 | super.init(coder: aDecoder) 47 | configureView() 48 | resizeSubviews() 49 | } 50 | 51 | public func resizeSubviews() { 52 | informationView.frame = bounds 53 | informationView.font = UIFont.systemFont(ofSize: max((bounds.width + bounds.height) / 30, 8)) 54 | informationView.configureLabel() 55 | informationView.setInformation(.default) 56 | informationView.setProgress(0) 57 | 58 | gridView.frame = bounds 59 | gridView.configureGrid() 60 | 61 | crossView.frame = bounds 62 | crossView.configureGrid() 63 | 64 | curveView.frame = CGRect(x: -frame.width / 2, y: -frame.height / 2, width: frame.width * 2, height: frame.height * 2) 65 | curveView.configureCurve() 66 | } 67 | 68 | func configureView() { 69 | isUserInteractionEnabled = false 70 | backgroundColor = .clear 71 | 72 | gridView.backgroundColor = viewColor.withAlphaComponent(0.2) 73 | addSubview(gridView) 74 | 75 | crossView.crossColor = viewColor.withAlphaComponent(0.5) 76 | addSubview(crossView) 77 | 78 | addSubview(curveView) 79 | 80 | informationView.textAlignment = .right 81 | informationView.textColor = viewColor.withAlphaComponent(0.5) 82 | addSubview(informationView) 83 | } 84 | 85 | public func climbingSituationDidChange(_ layer: MountainLayer, situation: ClimbingSituation) { 86 | switch situation { 87 | case .begin(let info): 88 | informationView.setInformation(info) 89 | informationView.setProgress(0) 90 | case .on(let progress, let curve): 91 | let point = CGPoint(x: frame.width * progress, y: frame.height - frame.height * curve) 92 | curveView.move(to: point) 93 | informationView.setProgress(progress) 94 | case .cancelled, .finished: 95 | curveView.reset() 96 | } 97 | } 98 | 99 | } 100 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | C71095BB1F1595EB00A3D59F /* Mountain.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C71095BA1F1595EB00A3D59F /* Mountain.framework */; }; 11 | C71095BC1F1595EB00A3D59F /* Mountain.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C71095BA1F1595EB00A3D59F /* Mountain.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 12 | C721ACCF1F1451260098376A /* MountainView.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = C721ACCA1F1450540098376A /* MountainView.framework */; }; 13 | C721ACD01F1451260098376A /* MountainView.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = C721ACCA1F1450540098376A /* MountainView.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 14 | C7EDA0D41E1C26C300E10A94 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7EDA0D31E1C26C300E10A94 /* AppDelegate.swift */; }; 15 | C7EDA0D61E1C26C300E10A94 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7EDA0D51E1C26C300E10A94 /* ViewController.swift */; }; 16 | C7EDA0D91E1C26C300E10A94 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C7EDA0D71E1C26C300E10A94 /* Main.storyboard */; }; 17 | C7EDA0DB1E1C26C300E10A94 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C7EDA0DA1E1C26C300E10A94 /* Assets.xcassets */; }; 18 | C7EDA0DE1E1C26C300E10A94 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C7EDA0DC1E1C26C300E10A94 /* LaunchScreen.storyboard */; }; 19 | C7EDA1041E1C2BC900E10A94 /* Storyboard.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7EDA1031E1C2BC900E10A94 /* Storyboard.swift */; }; 20 | C7EDA1061E1C2CFE00E10A94 /* NavigationController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7EDA1051E1C2CFE00E10A94 /* NavigationController.swift */; }; 21 | C7EDA1091E1C30FB00E10A94 /* MountainViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7EDA1081E1C30FB00E10A94 /* MountainViewController.swift */; }; 22 | /* End PBXBuildFile section */ 23 | 24 | /* Begin PBXContainerItemProxy section */ 25 | C721ACC91F1450540098376A /* PBXContainerItemProxy */ = { 26 | isa = PBXContainerItemProxy; 27 | containerPortal = C721ACC41F1450540098376A /* MountainView.xcodeproj */; 28 | proxyType = 2; 29 | remoteGlobalIDString = C7B4278A1DF45CCD008A27BD; 30 | remoteInfo = MountainView; 31 | }; 32 | C721ACD11F1451260098376A /* PBXContainerItemProxy */ = { 33 | isa = PBXContainerItemProxy; 34 | containerPortal = C721ACC41F1450540098376A /* MountainView.xcodeproj */; 35 | proxyType = 1; 36 | remoteGlobalIDString = C7B427891DF45CCD008A27BD; 37 | remoteInfo = MountainView; 38 | }; 39 | /* End PBXContainerItemProxy section */ 40 | 41 | /* Begin PBXCopyFilesBuildPhase section */ 42 | C721ACD31F1451260098376A /* Embed Frameworks */ = { 43 | isa = PBXCopyFilesBuildPhase; 44 | buildActionMask = 2147483647; 45 | dstPath = ""; 46 | dstSubfolderSpec = 10; 47 | files = ( 48 | C721ACD01F1451260098376A /* MountainView.framework in Embed Frameworks */, 49 | C71095BC1F1595EB00A3D59F /* Mountain.framework in Embed Frameworks */, 50 | ); 51 | name = "Embed Frameworks"; 52 | runOnlyForDeploymentPostprocessing = 0; 53 | }; 54 | /* End PBXCopyFilesBuildPhase section */ 55 | 56 | /* Begin PBXFileReference section */ 57 | C71095BA1F1595EB00A3D59F /* Mountain.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; path = Mountain.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | C721ACC41F1450540098376A /* MountainView.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = MountainView.xcodeproj; path = ../MountainView.xcodeproj; sourceTree = ""; }; 59 | C7EDA0D01E1C26C300E10A94 /* MountainViewExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = MountainViewExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 60 | C7EDA0D31E1C26C300E10A94 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 61 | C7EDA0D51E1C26C300E10A94 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 62 | C7EDA0D81E1C26C300E10A94 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 63 | C7EDA0DA1E1C26C300E10A94 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 64 | C7EDA0DD1E1C26C300E10A94 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 65 | C7EDA0DF1E1C26C300E10A94 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 66 | C7EDA1031E1C2BC900E10A94 /* Storyboard.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Storyboard.swift; sourceTree = ""; }; 67 | C7EDA1051E1C2CFE00E10A94 /* NavigationController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationController.swift; sourceTree = ""; }; 68 | C7EDA1081E1C30FB00E10A94 /* MountainViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = MountainViewController.swift; sourceTree = ""; }; 69 | /* End PBXFileReference section */ 70 | 71 | /* Begin PBXFrameworksBuildPhase section */ 72 | C7EDA0CD1E1C26C300E10A94 /* Frameworks */ = { 73 | isa = PBXFrameworksBuildPhase; 74 | buildActionMask = 2147483647; 75 | files = ( 76 | C721ACCF1F1451260098376A /* MountainView.framework in Frameworks */, 77 | C71095BB1F1595EB00A3D59F /* Mountain.framework in Frameworks */, 78 | ); 79 | runOnlyForDeploymentPostprocessing = 0; 80 | }; 81 | /* End PBXFrameworksBuildPhase section */ 82 | 83 | /* Begin PBXGroup section */ 84 | C721ACC51F1450540098376A /* Products */ = { 85 | isa = PBXGroup; 86 | children = ( 87 | C721ACCA1F1450540098376A /* MountainView.framework */, 88 | ); 89 | name = Products; 90 | sourceTree = ""; 91 | }; 92 | C7EDA0C71E1C26C300E10A94 = { 93 | isa = PBXGroup; 94 | children = ( 95 | C721ACC41F1450540098376A /* MountainView.xcodeproj */, 96 | C7EDA0D21E1C26C300E10A94 /* MountainViewExample */, 97 | C7EDA0D11E1C26C300E10A94 /* Products */, 98 | C7EDA0FA1E1C27DB00E10A94 /* Frameworks */, 99 | ); 100 | sourceTree = ""; 101 | }; 102 | C7EDA0D11E1C26C300E10A94 /* Products */ = { 103 | isa = PBXGroup; 104 | children = ( 105 | C7EDA0D01E1C26C300E10A94 /* MountainViewExample.app */, 106 | ); 107 | name = Products; 108 | sourceTree = ""; 109 | }; 110 | C7EDA0D21E1C26C300E10A94 /* MountainViewExample */ = { 111 | isa = PBXGroup; 112 | children = ( 113 | C7EDA0D31E1C26C300E10A94 /* AppDelegate.swift */, 114 | C7EDA0D51E1C26C300E10A94 /* ViewController.swift */, 115 | C7EDA0D71E1C26C300E10A94 /* Main.storyboard */, 116 | C7EDA1081E1C30FB00E10A94 /* MountainViewController.swift */, 117 | C7EDA1051E1C2CFE00E10A94 /* NavigationController.swift */, 118 | C7EDA1031E1C2BC900E10A94 /* Storyboard.swift */, 119 | C7EDA0DA1E1C26C300E10A94 /* Assets.xcassets */, 120 | C7EDA0DC1E1C26C300E10A94 /* LaunchScreen.storyboard */, 121 | C7EDA0DF1E1C26C300E10A94 /* Info.plist */, 122 | ); 123 | path = MountainViewExample; 124 | sourceTree = ""; 125 | }; 126 | C7EDA0FA1E1C27DB00E10A94 /* Frameworks */ = { 127 | isa = PBXGroup; 128 | children = ( 129 | C71095BA1F1595EB00A3D59F /* Mountain.framework */, 130 | ); 131 | name = Frameworks; 132 | sourceTree = ""; 133 | }; 134 | /* End PBXGroup section */ 135 | 136 | /* Begin PBXNativeTarget section */ 137 | C7EDA0CF1E1C26C300E10A94 /* MountainViewExample */ = { 138 | isa = PBXNativeTarget; 139 | buildConfigurationList = C7EDA0E21E1C26C300E10A94 /* Build configuration list for PBXNativeTarget "MountainViewExample" */; 140 | buildPhases = ( 141 | C7EDA0CC1E1C26C300E10A94 /* Sources */, 142 | C7EDA0CD1E1C26C300E10A94 /* Frameworks */, 143 | C7EDA0CE1E1C26C300E10A94 /* Resources */, 144 | C721ACD31F1451260098376A /* Embed Frameworks */, 145 | ); 146 | buildRules = ( 147 | ); 148 | dependencies = ( 149 | C721ACD21F1451260098376A /* PBXTargetDependency */, 150 | ); 151 | name = MountainViewExample; 152 | productName = MountainsViewExample; 153 | productReference = C7EDA0D01E1C26C300E10A94 /* MountainViewExample.app */; 154 | productType = "com.apple.product-type.application"; 155 | }; 156 | /* End PBXNativeTarget section */ 157 | 158 | /* Begin PBXProject section */ 159 | C7EDA0C81E1C26C300E10A94 /* Project object */ = { 160 | isa = PBXProject; 161 | attributes = { 162 | LastSwiftUpdateCheck = 0820; 163 | LastUpgradeCheck = 1000; 164 | ORGANIZATIONNAME = "Kyohei Ito"; 165 | TargetAttributes = { 166 | C7EDA0CF1E1C26C300E10A94 = { 167 | CreatedOnToolsVersion = 8.2.1; 168 | DevelopmentTeam = MX36A76L68; 169 | LastSwiftMigration = 1000; 170 | ProvisioningStyle = Automatic; 171 | }; 172 | }; 173 | }; 174 | buildConfigurationList = C7EDA0CB1E1C26C300E10A94 /* Build configuration list for PBXProject "MountainViewExample" */; 175 | compatibilityVersion = "Xcode 3.2"; 176 | developmentRegion = English; 177 | hasScannedForEncodings = 0; 178 | knownRegions = ( 179 | en, 180 | Base, 181 | ); 182 | mainGroup = C7EDA0C71E1C26C300E10A94; 183 | productRefGroup = C7EDA0D11E1C26C300E10A94 /* Products */; 184 | projectDirPath = ""; 185 | projectReferences = ( 186 | { 187 | ProductGroup = C721ACC51F1450540098376A /* Products */; 188 | ProjectRef = C721ACC41F1450540098376A /* MountainView.xcodeproj */; 189 | }, 190 | ); 191 | projectRoot = ""; 192 | targets = ( 193 | C7EDA0CF1E1C26C300E10A94 /* MountainViewExample */, 194 | ); 195 | }; 196 | /* End PBXProject section */ 197 | 198 | /* Begin PBXReferenceProxy section */ 199 | C721ACCA1F1450540098376A /* MountainView.framework */ = { 200 | isa = PBXReferenceProxy; 201 | fileType = wrapper.framework; 202 | path = MountainView.framework; 203 | remoteRef = C721ACC91F1450540098376A /* PBXContainerItemProxy */; 204 | sourceTree = BUILT_PRODUCTS_DIR; 205 | }; 206 | /* End PBXReferenceProxy section */ 207 | 208 | /* Begin PBXResourcesBuildPhase section */ 209 | C7EDA0CE1E1C26C300E10A94 /* Resources */ = { 210 | isa = PBXResourcesBuildPhase; 211 | buildActionMask = 2147483647; 212 | files = ( 213 | C7EDA0DE1E1C26C300E10A94 /* LaunchScreen.storyboard in Resources */, 214 | C7EDA0DB1E1C26C300E10A94 /* Assets.xcassets in Resources */, 215 | C7EDA0D91E1C26C300E10A94 /* Main.storyboard in Resources */, 216 | ); 217 | runOnlyForDeploymentPostprocessing = 0; 218 | }; 219 | /* End PBXResourcesBuildPhase section */ 220 | 221 | /* Begin PBXSourcesBuildPhase section */ 222 | C7EDA0CC1E1C26C300E10A94 /* Sources */ = { 223 | isa = PBXSourcesBuildPhase; 224 | buildActionMask = 2147483647; 225 | files = ( 226 | C7EDA0D61E1C26C300E10A94 /* ViewController.swift in Sources */, 227 | C7EDA1061E1C2CFE00E10A94 /* NavigationController.swift in Sources */, 228 | C7EDA1041E1C2BC900E10A94 /* Storyboard.swift in Sources */, 229 | C7EDA0D41E1C26C300E10A94 /* AppDelegate.swift in Sources */, 230 | C7EDA1091E1C30FB00E10A94 /* MountainViewController.swift in Sources */, 231 | ); 232 | runOnlyForDeploymentPostprocessing = 0; 233 | }; 234 | /* End PBXSourcesBuildPhase section */ 235 | 236 | /* Begin PBXTargetDependency section */ 237 | C721ACD21F1451260098376A /* PBXTargetDependency */ = { 238 | isa = PBXTargetDependency; 239 | name = MountainView; 240 | targetProxy = C721ACD11F1451260098376A /* PBXContainerItemProxy */; 241 | }; 242 | /* End PBXTargetDependency section */ 243 | 244 | /* Begin PBXVariantGroup section */ 245 | C7EDA0D71E1C26C300E10A94 /* Main.storyboard */ = { 246 | isa = PBXVariantGroup; 247 | children = ( 248 | C7EDA0D81E1C26C300E10A94 /* Base */, 249 | ); 250 | name = Main.storyboard; 251 | sourceTree = ""; 252 | }; 253 | C7EDA0DC1E1C26C300E10A94 /* LaunchScreen.storyboard */ = { 254 | isa = PBXVariantGroup; 255 | children = ( 256 | C7EDA0DD1E1C26C300E10A94 /* Base */, 257 | ); 258 | name = LaunchScreen.storyboard; 259 | sourceTree = ""; 260 | }; 261 | /* End PBXVariantGroup section */ 262 | 263 | /* Begin XCBuildConfiguration section */ 264 | C7EDA0E01E1C26C300E10A94 /* Debug */ = { 265 | isa = XCBuildConfiguration; 266 | buildSettings = { 267 | ALWAYS_SEARCH_USER_PATHS = NO; 268 | CLANG_ANALYZER_NONNULL = YES; 269 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 270 | CLANG_CXX_LIBRARY = "libc++"; 271 | CLANG_ENABLE_MODULES = YES; 272 | CLANG_ENABLE_OBJC_ARC = YES; 273 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 274 | CLANG_WARN_BOOL_CONVERSION = YES; 275 | CLANG_WARN_COMMA = YES; 276 | CLANG_WARN_CONSTANT_CONVERSION = YES; 277 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 278 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 279 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 280 | CLANG_WARN_EMPTY_BODY = YES; 281 | CLANG_WARN_ENUM_CONVERSION = YES; 282 | CLANG_WARN_INFINITE_RECURSION = YES; 283 | CLANG_WARN_INT_CONVERSION = YES; 284 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 285 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 286 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 287 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 288 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 289 | CLANG_WARN_STRICT_PROTOTYPES = YES; 290 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 291 | CLANG_WARN_UNREACHABLE_CODE = YES; 292 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 293 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 294 | COPY_PHASE_STRIP = NO; 295 | DEBUG_INFORMATION_FORMAT = dwarf; 296 | ENABLE_STRICT_OBJC_MSGSEND = YES; 297 | ENABLE_TESTABILITY = YES; 298 | GCC_C_LANGUAGE_STANDARD = gnu99; 299 | GCC_DYNAMIC_NO_PIC = NO; 300 | GCC_NO_COMMON_BLOCKS = YES; 301 | GCC_OPTIMIZATION_LEVEL = 0; 302 | GCC_PREPROCESSOR_DEFINITIONS = ( 303 | "DEBUG=1", 304 | "$(inherited)", 305 | ); 306 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 307 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 308 | GCC_WARN_UNDECLARED_SELECTOR = YES; 309 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 310 | GCC_WARN_UNUSED_FUNCTION = YES; 311 | GCC_WARN_UNUSED_VARIABLE = YES; 312 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 313 | MTL_ENABLE_DEBUG_INFO = YES; 314 | ONLY_ACTIVE_ARCH = YES; 315 | SDKROOT = iphoneos; 316 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; 317 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 318 | }; 319 | name = Debug; 320 | }; 321 | C7EDA0E11E1C26C300E10A94 /* Release */ = { 322 | isa = XCBuildConfiguration; 323 | buildSettings = { 324 | ALWAYS_SEARCH_USER_PATHS = NO; 325 | CLANG_ANALYZER_NONNULL = YES; 326 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 327 | CLANG_CXX_LIBRARY = "libc++"; 328 | CLANG_ENABLE_MODULES = YES; 329 | CLANG_ENABLE_OBJC_ARC = YES; 330 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; 331 | CLANG_WARN_BOOL_CONVERSION = YES; 332 | CLANG_WARN_COMMA = YES; 333 | CLANG_WARN_CONSTANT_CONVERSION = YES; 334 | CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; 335 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 336 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES; 337 | CLANG_WARN_EMPTY_BODY = YES; 338 | CLANG_WARN_ENUM_CONVERSION = YES; 339 | CLANG_WARN_INFINITE_RECURSION = YES; 340 | CLANG_WARN_INT_CONVERSION = YES; 341 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; 342 | CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; 343 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; 344 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 345 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; 346 | CLANG_WARN_STRICT_PROTOTYPES = YES; 347 | CLANG_WARN_SUSPICIOUS_MOVE = YES; 348 | CLANG_WARN_UNREACHABLE_CODE = YES; 349 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 350 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 351 | COPY_PHASE_STRIP = NO; 352 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 353 | ENABLE_NS_ASSERTIONS = NO; 354 | ENABLE_STRICT_OBJC_MSGSEND = YES; 355 | GCC_C_LANGUAGE_STANDARD = gnu99; 356 | GCC_NO_COMMON_BLOCKS = YES; 357 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 358 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 359 | GCC_WARN_UNDECLARED_SELECTOR = YES; 360 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 361 | GCC_WARN_UNUSED_FUNCTION = YES; 362 | GCC_WARN_UNUSED_VARIABLE = YES; 363 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 364 | MTL_ENABLE_DEBUG_INFO = NO; 365 | SDKROOT = iphoneos; 366 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; 367 | VALIDATE_PRODUCT = YES; 368 | }; 369 | name = Release; 370 | }; 371 | C7EDA0E31E1C26C300E10A94 /* Debug */ = { 372 | isa = XCBuildConfiguration; 373 | buildSettings = { 374 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 375 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 376 | DEVELOPMENT_TEAM = MX36A76L68; 377 | INFOPLIST_FILE = MountainViewExample/Info.plist; 378 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 379 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 380 | PRODUCT_BUNDLE_IDENTIFIER = com.kyoheiito.MountainViewExample; 381 | PRODUCT_NAME = "$(TARGET_NAME)"; 382 | SWIFT_VERSION = 4.2; 383 | }; 384 | name = Debug; 385 | }; 386 | C7EDA0E41E1C26C300E10A94 /* Release */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES; 390 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 391 | DEVELOPMENT_TEAM = MX36A76L68; 392 | INFOPLIST_FILE = MountainViewExample/Info.plist; 393 | IPHONEOS_DEPLOYMENT_TARGET = 9.0; 394 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 395 | PRODUCT_BUNDLE_IDENTIFIER = com.kyoheiito.MountainViewExample; 396 | PRODUCT_NAME = "$(TARGET_NAME)"; 397 | SWIFT_VERSION = 4.2; 398 | }; 399 | name = Release; 400 | }; 401 | /* End XCBuildConfiguration section */ 402 | 403 | /* Begin XCConfigurationList section */ 404 | C7EDA0CB1E1C26C300E10A94 /* Build configuration list for PBXProject "MountainViewExample" */ = { 405 | isa = XCConfigurationList; 406 | buildConfigurations = ( 407 | C7EDA0E01E1C26C300E10A94 /* Debug */, 408 | C7EDA0E11E1C26C300E10A94 /* Release */, 409 | ); 410 | defaultConfigurationIsVisible = 0; 411 | defaultConfigurationName = Release; 412 | }; 413 | C7EDA0E21E1C26C300E10A94 /* Build configuration list for PBXNativeTarget "MountainViewExample" */ = { 414 | isa = XCConfigurationList; 415 | buildConfigurations = ( 416 | C7EDA0E31E1C26C300E10A94 /* Debug */, 417 | C7EDA0E41E1C26C300E10A94 /* Release */, 418 | ); 419 | defaultConfigurationIsVisible = 0; 420 | defaultConfigurationName = Release; 421 | }; 422 | /* End XCConfigurationList section */ 423 | }; 424 | rootObject = C7EDA0C81E1C26C300E10A94 /* Project object */; 425 | } 426 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | IDEDidComputeMac32BitWarning 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // MountainViewExample 4 | // 5 | // Created by Kyohei Ito on 2017/01/04. 6 | // Copyright © 2017年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MountainView 11 | 12 | @UIApplicationMain 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | let mountainWindow = UIWindow(frame: UIScreen.main.bounds) 17 | 18 | func climb() { 19 | (mountainWindow.rootViewController as? MountainViewController)?.mountainView?.climb() 20 | } 21 | 22 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { 23 | // Override point for customization after application launch. 24 | mountainWindow.isUserInteractionEnabled = false 25 | mountainWindow.rootViewController = MountainViewController.makeFromStoryboard() 26 | 27 | DispatchQueue.main.async { 28 | self.mountainWindow.makeKeyAndVisible() 29 | } 30 | 31 | return true 32 | } 33 | 34 | func applicationWillResignActive(_ application: UIApplication) { 35 | // 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. 36 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game. 37 | } 38 | 39 | func applicationDidEnterBackground(_ application: UIApplication) { 40 | // 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. 41 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 42 | } 43 | 44 | func applicationWillEnterForeground(_ application: UIApplication) { 45 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background. 46 | } 47 | 48 | func applicationDidBecomeActive(_ application: UIApplication) { 49 | // 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. 50 | } 51 | 52 | func applicationWillTerminate(_ application: UIApplication) { 53 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 54 | } 55 | 56 | 57 | } 58 | 59 | extension UIApplication { 60 | static var appDelegate: AppDelegate? { 61 | return shared.delegate as? AppDelegate 62 | } 63 | } 64 | 65 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "20x20", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "20x20", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "29x29", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "29x29", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "40x40", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "40x40", 31 | "scale" : "3x" 32 | }, 33 | { 34 | "idiom" : "iphone", 35 | "size" : "60x60", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "iphone", 40 | "size" : "60x60", 41 | "scale" : "3x" 42 | } 43 | ], 44 | "info" : { 45 | "version" : 1, 46 | "author" : "xcode" 47 | } 48 | } -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/Base.lproj/LaunchScreen.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 33 | 40 | 47 | 54 | 61 | 68 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/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 | CFBundleVersion 20 | 1 21 | LSRequiresIPhoneOS 22 | 23 | UILaunchStoryboardName 24 | LaunchScreen 25 | UIMainStoryboardFile 26 | Main 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/MountainViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // MountainViewController.swift 3 | // MountainViewExample 4 | // 5 | // Created by Kyohei Ito on 2017/01/04. 6 | // Copyright © 2017年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import MountainView 11 | 12 | class MountainViewController: UIViewController, Storyboard { 13 | @IBOutlet weak var mountainView: MountainView! 14 | 15 | static var storyboardName: String { 16 | return "Main" 17 | } 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | // Do any additional setup after loading the view. 22 | } 23 | 24 | override func didReceiveMemoryWarning() { 25 | super.didReceiveMemoryWarning() 26 | // Dispose of any resources that can be recreated. 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/NavigationController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // NavigationController.swift 3 | // MountainViewExample 4 | // 5 | // Created by Kyohei Ito on 2017/01/04. 6 | // Copyright © 2017年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class NavigationController: UINavigationController, Storyboard { 12 | static var storyboardName: String { 13 | return "Main" 14 | } 15 | 16 | override func viewDidLoad() { 17 | super.viewDidLoad() 18 | // Do any additional setup after loading the view. 19 | } 20 | 21 | override func didReceiveMemoryWarning() { 22 | super.didReceiveMemoryWarning() 23 | // Dispose of any resources that can be recreated. 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/Storyboard.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Storyboard.swift 3 | // MountainViewExample 4 | // 5 | // Created by Kyohei Ito on 2017/01/04. 6 | // Copyright © 2017年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | private extension NSObjectProtocol { 12 | static var className: String { 13 | return String(describing: self) 14 | } 15 | } 16 | 17 | protocol Storyboard: NSObjectProtocol { 18 | associatedtype Instance 19 | static func makeFromStoryboard() -> Instance 20 | static var storyboard: UIStoryboard { get } 21 | static var storyboardName: String { get } 22 | static var identifier: String { get } 23 | } 24 | 25 | extension Storyboard { 26 | static var storyboardName: String { 27 | return className 28 | } 29 | 30 | static var identifier: String { 31 | return className 32 | } 33 | 34 | static var storyboard: UIStoryboard { 35 | return UIStoryboard(name: storyboardName, bundle: nil) 36 | } 37 | 38 | static func makeFromStoryboard() -> Self { 39 | return storyboard.instantiateViewController(withIdentifier: identifier) as! Self 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /MountainViewExample/MountainViewExample/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // MountainViewExample 4 | // 5 | // Created by Kyohei Ito on 2017/01/04. 6 | // Copyright © 2017年 Kyohei Ito. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Mountain 11 | 12 | class ViewController: UIViewController, Storyboard { 13 | let mountain = Mountain() 14 | 15 | static var storyboardName: String { 16 | return "Main" 17 | } 18 | 19 | override func viewDidLoad() { 20 | super.viewDidLoad() 21 | // Do any additional setup after loading the view, typically from a nib. 22 | } 23 | 24 | override func didReceiveMemoryWarning() { 25 | super.didReceiveMemoryWarning() 26 | // Dispose of any resources that can be recreated. 27 | } 28 | 29 | override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) { 30 | super.viewWillTransition(to: size, with: coordinator) 31 | 32 | coordinator.animate(alongsideTransition: { _ in 33 | UIApplication.appDelegate?.climb() 34 | }, completion: nil) 35 | } 36 | 37 | func climbMountain() { 38 | transitionCoordinator?.animate(alongsideTransition: { _ in 39 | UIApplication.appDelegate?.climb() 40 | }, completion: nil) 41 | } 42 | 43 | override var prefersStatusBarHidden: Bool { 44 | return false 45 | } 46 | } 47 | 48 | extension ViewController { 49 | @IBAction func push() { 50 | let controller = ViewController.makeFromStoryboard() 51 | navigationController?.pushViewController(controller, animated: true) 52 | climbMountain() 53 | } 54 | 55 | @IBAction func pop() { 56 | _ = navigationController?.popViewController(animated: true) 57 | climbMountain() 58 | } 59 | 60 | @IBAction func present() { 61 | let controller = NavigationController.makeFromStoryboard() 62 | present(controller, animated: true, completion: nil) 63 | climbMountain() 64 | } 65 | 66 | @IBAction func dismiss() { 67 | presentingViewController?.dismiss(animated: true, completion: nil) 68 | climbMountain() 69 | } 70 | 71 | @IBAction func curveLinear() { 72 | UIView.animate(withDuration: 0.3, delay: 0, options: [.curveLinear], animations: { 73 | self.mountain.climb() 74 | .situation { 75 | print($0) 76 | } 77 | UIApplication.appDelegate?.climb() 78 | }, completion: nil) 79 | } 80 | 81 | @IBAction func curveEaseIn() { 82 | UIView.animate(withDuration: 0.3, delay: 0, options: [.curveEaseIn], animations: { 83 | self.mountain.climb() 84 | .situation { 85 | print($0) 86 | } 87 | UIApplication.appDelegate?.climb() 88 | }, completion: nil) 89 | } 90 | 91 | @IBAction func curveEaseOut() { 92 | UIView.animate(withDuration: 0.3, delay: 0, options: [.curveEaseOut], animations: { 93 | self.mountain.climb() 94 | .situation { 95 | print($0) 96 | } 97 | UIApplication.appDelegate?.climb() 98 | }, completion: nil) 99 | } 100 | } 101 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![logo](https://user-images.githubusercontent.com/5707132/46053616-9256c400-c17e-11e8-955b-8b06d387302b.png) 2 | 3 | 4 | [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) 5 | [![Version](https://img.shields.io/cocoapods/v/MountainView.svg?style=flat)](http://cocoadocs.org/docsets/MountainView) 6 | [![License](https://img.shields.io/cocoapods/l/MountainView.svg?style=flat)](http://cocoadocs.org/docsets/MountainView) 7 | [![Platform](https://img.shields.io/cocoapods/p/MountainView.svg?style=flat)](http://cocoadocs.org/docsets/MountainView) 8 | 9 | The animation curve looks like Mountain View. 10 | 11 | #### [Appetize's Demo](https://appetize.io/app/4gktrxnmf67ahr6tkpeut4kqvc) 12 | 13 | ## Over View 14 | 15 | It consists of Mountain for visualizing animation and MountainView for graphing it. 16 | 17 | ![graph](https://user-images.githubusercontent.com/5707132/46053575-6a676080-c17e-11e8-8c1c-73688d5fd6e8.png) 18 | 19 | #### Mountain 20 | 21 | You can visualize the type and easing of the animation executed. 22 | For example, if you execute as follows, you can output the progress in the log. 23 | 24 | ```swift 25 | let mountain = Mountain() 26 | UIView.animate(withDuration: 0.3) { 27 | mountain.climb(retainSelf: true) 28 | .situation { 29 | print($0) 30 | } 31 | } 32 | ``` 33 | 34 | Execution log. 35 | 36 | ``` 37 | begin(Mountain.Information(type: "CABasicAnimation", delay: 0.0, duration: 0.29999999999999999, reverse: false, repeatCount: 0.0, function: Optional(easeInEaseOut))) 38 | on(progress: 0.0641036704182625, curve: 0.0977618917822838) 39 | on(progress: 0.12283568829298, curve: 0.188721746206284) 40 | on(progress: 0.182344779372215, curve: 0.276777744293213) 41 | on(progress: 0.243786245584488, curve: 0.363606035709381) 42 | on(progress: 0.303644210100174, curve: 0.444229960441589) 43 | on(progress: 0.362437427043915, curve: 0.519574403762817) 44 | on(progress: 0.420619368553162, curve: 0.59021383523941) 45 | on(progress: 0.481439799070358, curve: 0.659674882888794) 46 | on(progress: 0.54224693775177, curve: 0.724372625350952) 47 | on(progress: 0.600623190402985, curve: 0.781640827655792) 48 | on(progress: 0.659852802753448, curve: 0.834497272968292) 49 | on(progress: 0.718149065971375, curve: 0.880844235420227) 50 | on(progress: 0.77815580368042, curve: 0.922019064426422) 51 | on(progress: 0.838306427001953, curve: 0.955803155899048) 52 | on(progress: 0.899652481079102, curve: 0.981418073177338) 53 | on(progress: 0.958390593528748, curve: 0.99620121717453) 54 | on(progress: 1.0, curve: 1.0) 55 | ``` 56 | 57 | Since Mountain does not depend on MountainView, it can be used by itself and is lightweight. 58 | 59 | #### MountainView 60 | 61 | By creating MountainView with Interface Builder, animation can be easily graphed. 62 | 63 | ```swift 64 | @IBOutlet weak var mountainView: MountainView! 65 | 66 | UIView.animate(withDuration: 0.3) { 67 | self.mountainView.climb() 68 | } 69 | ``` 70 | 71 | ## Requirements 72 | 73 | - Swift 3.0 74 | - iOS 9.0 or later 75 | 76 | ## How to Install 77 | 78 | MountainView depends on Mountain. 79 | 80 | #### CocoaPods 81 | 82 | Add the following to your `Podfile`: 83 | 84 | ```Ruby 85 | pod "Mountain" 86 | ``` 87 | 88 | or 89 | 90 | ```Ruby 91 | pod "MountainView" 92 | ``` 93 | 94 | #### Carthage 95 | 96 | Add the following to your `Cartfile`: 97 | 98 | ```Ruby 99 | github "KyoheiG3/MountainView" 100 | ``` 101 | 102 | ## Usage 103 | 104 | ### Mountain 105 | 106 | #### Climbingable: ClimbDownable (Mountain) 107 | 108 | Start and stop get of animation. 109 | 110 | ```swift 111 | public func climb(retainSelf: Bool = default) -> Climber 112 | public func climbDown() 113 | ``` 114 | 115 | Get can be interrupted by executing `climbDown`. 116 | 117 | ```swift 118 | let mountain = Mountain() 119 | UIView.animate(withDuration: 0.3) { 120 | mountain.climb(retainSelf: true) 121 | } 122 | mountain.climbDown() 123 | ``` 124 | 125 | #### Climber: ClimbFinishable 126 | 127 | Get the progress of the animation. 128 | 129 | ```swift 130 | public func situation(_ handler: @escaping (ClimbingSituation) -> Void) -> ClimbFinishable 131 | public func filter(_ handler: @escaping (CGFloat, CGFloat) -> Bool) -> Self 132 | public func map(_ handler: @escaping (CGFloat) -> CGFloat) -> Self 133 | public func finish(_ handler: @escaping (ClimbingSituation) -> Void) 134 | ``` 135 | 136 | You can also filter and change the data. 137 | 138 | ```swift 139 | let mountain = Mountain() 140 | UIView.animate(withDuration: 0.3) { 141 | mountain.climb(retainSelf: true) 142 | .filter { progress, curve -> Bool in 143 | progress > 0.5 144 | } 145 | .map { curve in 146 | ceil(curve * 100) 147 | } 148 | .situation { 149 | print($0) 150 | } 151 | .finish { 152 | print($0) 153 | } 154 | } 155 | ``` 156 | 157 | Execution log. 158 | 159 | ``` 160 | begin(Mountain.Information(type: "CABasicAnimation", delay: 0.0, duration: 0.29999999999999999, reverse: false, repeatCount: 0.0, function: Optional(easeInEaseOut))) 161 | on(progress: 0.543500006198883, curve: 73.0) 162 | on(progress: 0.602446019649506, curve: 79.0) 163 | on(progress: 0.661734223365784, curve: 84.0) 164 | on(progress: 0.72049480676651, curve: 89.0) 165 | on(progress: 0.779515981674194, curve: 93.0) 166 | on(progress: 0.841407358646393, curve: 96.0) 167 | on(progress: 0.899605870246887, curve: 99.0) 168 | on(progress: 0.961408495903015, curve: 100.0) 169 | on(progress: 1.0, curve: 100.0) 170 | finished 171 | ``` 172 | 173 | #### ClimbingSituation 174 | 175 | An enum to know the progress of animation. 176 | 177 | ```swift 178 | case begin(info: Information) 179 | case on(progress: CGFloat, curve: CGFloat) 180 | case cancelled 181 | case finished 182 | ``` 183 | 184 | #### Information 185 | 186 | It's information about animation. 187 | 188 | ```swift 189 | public static let `default`: Information 190 | public let type: String 191 | public let delay: CFTimeInterval 192 | public let duration: CFTimeInterval 193 | public let reverse: Bool 194 | public let repeatCount: Float 195 | public let function: CAMediaTimingFunction? 196 | ``` 197 | 198 | #### MountainLayerDelegate 199 | 200 | It's also possible to get the progress of the animation with the delegate method. 201 | 202 | ```swift 203 | public func climbingSituationDidChange(_ layer: MountainLayer, situation: ClimbingSituation) 204 | ``` 205 | 206 | #### MountainLayerHaving: Climbingable 207 | 208 | Use it when `UIView` wants to know the progress of animation by itself. 209 | 210 | ```swift 211 | public func climb() -> Climber 212 | public func climbDown() 213 | ``` 214 | 215 | It's necessary to prepare `MountainLayer` as follows. 216 | 217 | ```swift 218 | class View: UIView, MountainLayerHaving { 219 | override class var layerClass: AnyClass { 220 | return MountainLayer.self 221 | } 222 | var mountainLayer: MountainLayer { 223 | return layer as! MountainLayer 224 | } 225 | } 226 | ``` 227 | 228 | #### UIView extension 229 | 230 | You can get progress from the animation block. 231 | 232 | ```swift 233 | open class func animate(withDuration duration: TimeInterval, delay: TimeInterval = default, options: UIViewAnimationOptions = default, retain: Bool = default, animations: @escaping () -> Void = default, situation: @escaping (ClimbingSituation) -> Void, completion: ((Bool) -> Void)? = default) -> ClimbDownable? 234 | open class func animate(withDuration duration: TimeInterval, delay: TimeInterval = default, usingSpringWithDamping dampingRatio: CGFloat, initialSpringVelocity velocity: CGFloat, options: UIViewAnimationOptions = default, retain: Bool = default, animations: @escaping () -> Void = default, situation: @escaping (ClimbingSituation) -> Void, completion: ((Bool) -> Void)? = default) -> ClimbDownable? 235 | ``` 236 | 237 | ### MountainView 238 | 239 | It's a subclass of `UIView` conforming to `MountainLayerHaving`. 240 | 241 | You can generate a MountainView with Interface Builder and graph the easing of the animation. 242 | 243 | ```swift 244 | @IBOutlet weak var mountainView: MountainView! 245 | 246 | UIView.animate(withDuration: 0.3) { 247 | self.mountainView.climb() 248 | } 249 | ``` 250 | 251 | screen 252 | 253 | ## LICENSE 254 | 255 | Under the MIT license. See LICENSE file for details. 256 | --------------------------------------------------------------------------------