├── .gitignore ├── Assets ├── 1.gif └── header.png ├── LICENSE ├── Popsicle.podspec ├── Popsicle.xcodeproj ├── project.pbxproj ├── project.xcworkspace │ └── contents.xcworkspacedata └── xcshareddata │ └── xcschemes │ └── Popsicle.xcscheme ├── Popsicle ├── EasingFunction.swift ├── Info.plist ├── Interpolable.swift ├── Interpolation.swift ├── Interpolator.swift ├── KeyPath.swift └── Popsicle.h ├── PopsicleDemo ├── AppDelegate.swift ├── Assets.xcassets │ ├── AppIcon.appiconset │ │ ├── Contents.json │ │ ├── Icon-29.png │ │ ├── Icon-29@2x-1.png │ │ ├── Icon-29@2x.png │ │ ├── Icon-29@3x.png │ │ ├── Icon-40.png │ │ ├── Icon-40@2x-1.png │ │ ├── Icon-40@2x.png │ │ ├── Icon-40@3x.png │ │ ├── Icon-60@2x.png │ │ ├── Icon-60@3x.png │ │ ├── Icon-76.png │ │ ├── Icon-76@2x.png │ │ └── Icon-83.5@2x.png │ ├── Contents.json │ └── logo.imageset │ │ ├── Contents.json │ │ └── logo.pdf ├── Base.lproj │ └── LaunchScreen.storyboard ├── DRPageScrollView.h ├── DRPageScrollView.m ├── Info.plist ├── PageScrollView.swift ├── PageViews.xib ├── PopsicleDemo-Bridging-Header.h ├── UIView+Utils.swift └── ViewController.swift └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # OS X 2 | 3 | .DS_Store 4 | 5 | # Xcode 6 | 7 | build/ 8 | *.pbxuser 9 | !default.pbxuser 10 | *.mode1v3 11 | !default.mode1v3 12 | *.mode2v3 13 | !default.mode2v3 14 | *.perspectivev3 15 | !default.perspectivev3 16 | xcuserdata 17 | *.xccheckout 18 | *.moved-aside 19 | DerivedData 20 | *.hmap 21 | *.ipa 22 | *.xcuserstate 23 | -------------------------------------------------------------------------------- /Assets/1.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/Assets/1.gif -------------------------------------------------------------------------------- /Assets/header.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/Assets/header.png -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 IFTTT Inc 4 | Copyright (c) 2015 David Román 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in 14 | all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 19 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 21 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 22 | THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /Popsicle.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "Popsicle" 3 | s.version = "2.0.1" 4 | s.summary = "Delightful, extensible Swift value interpolation framework" 5 | s.homepage = "https://github.com/DavdRoman/Popsicle" 6 | s.author = { "David Román" => "d@vidroman.me" } 7 | s.license = { :type => 'MIT', :file => 'LICENSE' } 8 | s.social_media_url = 'https://twitter.com/DavdRoman' 9 | 10 | s.platform = :ios, '8.0' 11 | s.ios.deployment_target = '8.0' 12 | 13 | s.source = { :git => "https://github.com/DavdRoman/Popsicle.git", :tag => s.version.to_s } 14 | s.source_files = 'Popsicle/*.{h,swift}' 15 | s.frameworks = 'UIKit' 16 | s.requires_arc = true 17 | end 18 | -------------------------------------------------------------------------------- /Popsicle.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | D53B324C1BE65FF800A1820B /* Interpolable.swift in Sources */ = {isa = PBXBuildFile; fileRef = D53B324B1BE65FF800A1820B /* Interpolable.swift */; }; 11 | D53E5FD91BEA12340043DF84 /* EasingFunction.swift in Sources */ = {isa = PBXBuildFile; fileRef = D53E5FD81BEA12340043DF84 /* EasingFunction.swift */; }; 12 | D53E5FDB1BEA13600043DF84 /* Interpolation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D53E5FDA1BEA13600043DF84 /* Interpolation.swift */; }; 13 | D53E5FDD1BEA13900043DF84 /* Interpolator.swift in Sources */ = {isa = PBXBuildFile; fileRef = D53E5FDC1BEA13900043DF84 /* Interpolator.swift */; }; 14 | D53E5FE51BEA145F0043DF84 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = D53E5FE41BEA145F0043DF84 /* AppDelegate.swift */; }; 15 | D53E5FE71BEA145F0043DF84 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D53E5FE61BEA145F0043DF84 /* ViewController.swift */; }; 16 | D53E5FEC1BEA145F0043DF84 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = D53E5FEB1BEA145F0043DF84 /* Assets.xcassets */; }; 17 | D53E5FEF1BEA145F0043DF84 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = D53E5FED1BEA145F0043DF84 /* LaunchScreen.storyboard */; }; 18 | D53E5FF71BEA16D70043DF84 /* PageViews.xib in Resources */ = {isa = PBXBuildFile; fileRef = D53E5FF61BEA16D70043DF84 /* PageViews.xib */; }; 19 | D53E60011BEA203B0043DF84 /* PageScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = D53E5FFF1BEA199C0043DF84 /* PageScrollView.swift */; }; 20 | D53E60021BEA227D0043DF84 /* DRPageScrollView.m in Sources */ = {isa = PBXBuildFile; fileRef = D53E5FFA1BEA18140043DF84 /* DRPageScrollView.m */; }; 21 | D53E60051BEA67790043DF84 /* UIView+Utils.swift in Sources */ = {isa = PBXBuildFile; fileRef = D53E60041BEA67790043DF84 /* UIView+Utils.swift */; }; 22 | D593A8DD1BEA72E500AFA257 /* Popsicle.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D5FBF53A1BE65BB500F3CB79 /* Popsicle.framework */; }; 23 | D593A8DE1BEA72E500AFA257 /* Popsicle.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = D5FBF53A1BE65BB500F3CB79 /* Popsicle.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; }; 24 | D5D6A94C1BEBB85A008E414E /* KeyPath.swift in Sources */ = {isa = PBXBuildFile; fileRef = D593A8E41BEA88B600AFA257 /* KeyPath.swift */; }; 25 | D5FBF53E1BE65BB500F3CB79 /* Popsicle.h in Headers */ = {isa = PBXBuildFile; fileRef = D5FBF53D1BE65BB500F3CB79 /* Popsicle.h */; settings = {ATTRIBUTES = (Public, ); }; }; 26 | /* End PBXBuildFile section */ 27 | 28 | /* Begin PBXContainerItemProxy section */ 29 | D593A8DF1BEA72E500AFA257 /* PBXContainerItemProxy */ = { 30 | isa = PBXContainerItemProxy; 31 | containerPortal = D5FBF5311BE65BB500F3CB79 /* Project object */; 32 | proxyType = 1; 33 | remoteGlobalIDString = D5FBF5391BE65BB500F3CB79; 34 | remoteInfo = Popsicle; 35 | }; 36 | /* End PBXContainerItemProxy section */ 37 | 38 | /* Begin PBXCopyFilesBuildPhase section */ 39 | D593A8E11BEA72E500AFA257 /* Embed Frameworks */ = { 40 | isa = PBXCopyFilesBuildPhase; 41 | buildActionMask = 2147483647; 42 | dstPath = ""; 43 | dstSubfolderSpec = 10; 44 | files = ( 45 | D593A8DE1BEA72E500AFA257 /* Popsicle.framework in Embed Frameworks */, 46 | ); 47 | name = "Embed Frameworks"; 48 | runOnlyForDeploymentPostprocessing = 0; 49 | }; 50 | /* End PBXCopyFilesBuildPhase section */ 51 | 52 | /* Begin PBXFileReference section */ 53 | D53B324B1BE65FF800A1820B /* Interpolable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Interpolable.swift; sourceTree = ""; }; 54 | D53E5FD81BEA12340043DF84 /* EasingFunction.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = EasingFunction.swift; sourceTree = ""; }; 55 | D53E5FDA1BEA13600043DF84 /* Interpolation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Interpolation.swift; sourceTree = ""; }; 56 | D53E5FDC1BEA13900043DF84 /* Interpolator.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Interpolator.swift; sourceTree = ""; }; 57 | D53E5FE21BEA145F0043DF84 /* PopsicleDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PopsicleDemo.app; sourceTree = BUILT_PRODUCTS_DIR; }; 58 | D53E5FE41BEA145F0043DF84 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; 59 | D53E5FE61BEA145F0043DF84 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; }; 60 | D53E5FEB1BEA145F0043DF84 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; 61 | D53E5FEE1BEA145F0043DF84 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; 62 | D53E5FF01BEA145F0043DF84 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 63 | D53E5FF61BEA16D70043DF84 /* PageViews.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = PageViews.xib; sourceTree = ""; }; 64 | D53E5FF81BEA18130043DF84 /* PopsicleDemo-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "PopsicleDemo-Bridging-Header.h"; sourceTree = ""; }; 65 | D53E5FF91BEA18140043DF84 /* DRPageScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DRPageScrollView.h; sourceTree = ""; }; 66 | D53E5FFA1BEA18140043DF84 /* DRPageScrollView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = DRPageScrollView.m; sourceTree = ""; }; 67 | D53E5FFF1BEA199C0043DF84 /* PageScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageScrollView.swift; sourceTree = ""; }; 68 | D53E60041BEA67790043DF84 /* UIView+Utils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "UIView+Utils.swift"; sourceTree = ""; }; 69 | D593A8E41BEA88B600AFA257 /* KeyPath.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KeyPath.swift; sourceTree = ""; }; 70 | D5FBF53A1BE65BB500F3CB79 /* Popsicle.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Popsicle.framework; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | D5FBF53D1BE65BB500F3CB79 /* Popsicle.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = Popsicle.h; sourceTree = ""; }; 72 | D5FBF53F1BE65BB500F3CB79 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 73 | /* End PBXFileReference section */ 74 | 75 | /* Begin PBXFrameworksBuildPhase section */ 76 | D53E5FDF1BEA145F0043DF84 /* Frameworks */ = { 77 | isa = PBXFrameworksBuildPhase; 78 | buildActionMask = 2147483647; 79 | files = ( 80 | D593A8DD1BEA72E500AFA257 /* Popsicle.framework in Frameworks */, 81 | ); 82 | runOnlyForDeploymentPostprocessing = 0; 83 | }; 84 | D5FBF5361BE65BB500F3CB79 /* Frameworks */ = { 85 | isa = PBXFrameworksBuildPhase; 86 | buildActionMask = 2147483647; 87 | files = ( 88 | ); 89 | runOnlyForDeploymentPostprocessing = 0; 90 | }; 91 | /* End PBXFrameworksBuildPhase section */ 92 | 93 | /* Begin PBXGroup section */ 94 | D516D8DF1D1A90910086E8E6 /* Supporting Files */ = { 95 | isa = PBXGroup; 96 | children = ( 97 | D53E5FEB1BEA145F0043DF84 /* Assets.xcassets */, 98 | D53E5FED1BEA145F0043DF84 /* LaunchScreen.storyboard */, 99 | D53E5FF01BEA145F0043DF84 /* Info.plist */, 100 | ); 101 | name = "Supporting Files"; 102 | sourceTree = ""; 103 | }; 104 | D53E5FE31BEA145F0043DF84 /* PopsicleDemo */ = { 105 | isa = PBXGroup; 106 | children = ( 107 | D53E5FE41BEA145F0043DF84 /* AppDelegate.swift */, 108 | D53E5FE61BEA145F0043DF84 /* ViewController.swift */, 109 | D5F2E3E11BEB720B00008043 /* Page Scroll View */, 110 | D516D8DF1D1A90910086E8E6 /* Supporting Files */, 111 | ); 112 | path = PopsicleDemo; 113 | sourceTree = ""; 114 | }; 115 | D5F2E3E11BEB720B00008043 /* Page Scroll View */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | D53E5FF81BEA18130043DF84 /* PopsicleDemo-Bridging-Header.h */, 119 | D53E5FF91BEA18140043DF84 /* DRPageScrollView.h */, 120 | D53E5FFA1BEA18140043DF84 /* DRPageScrollView.m */, 121 | D53E5FFF1BEA199C0043DF84 /* PageScrollView.swift */, 122 | D53E5FF61BEA16D70043DF84 /* PageViews.xib */, 123 | D53E60041BEA67790043DF84 /* UIView+Utils.swift */, 124 | ); 125 | name = "Page Scroll View"; 126 | sourceTree = ""; 127 | }; 128 | D5FBF5301BE65BB500F3CB79 = { 129 | isa = PBXGroup; 130 | children = ( 131 | D53E5FE31BEA145F0043DF84 /* PopsicleDemo */, 132 | D5FBF53C1BE65BB500F3CB79 /* Popsicle */, 133 | D5FBF53B1BE65BB500F3CB79 /* Products */, 134 | ); 135 | sourceTree = ""; 136 | }; 137 | D5FBF53B1BE65BB500F3CB79 /* Products */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | D5FBF53A1BE65BB500F3CB79 /* Popsicle.framework */, 141 | D53E5FE21BEA145F0043DF84 /* PopsicleDemo.app */, 142 | ); 143 | name = Products; 144 | sourceTree = ""; 145 | }; 146 | D5FBF53C1BE65BB500F3CB79 /* Popsicle */ = { 147 | isa = PBXGroup; 148 | children = ( 149 | D5FBF53D1BE65BB500F3CB79 /* Popsicle.h */, 150 | D53E5FDC1BEA13900043DF84 /* Interpolator.swift */, 151 | D53E5FDA1BEA13600043DF84 /* Interpolation.swift */, 152 | D53B324B1BE65FF800A1820B /* Interpolable.swift */, 153 | D53E5FD81BEA12340043DF84 /* EasingFunction.swift */, 154 | D593A8E41BEA88B600AFA257 /* KeyPath.swift */, 155 | D5FBF53F1BE65BB500F3CB79 /* Info.plist */, 156 | ); 157 | path = Popsicle; 158 | sourceTree = ""; 159 | }; 160 | /* End PBXGroup section */ 161 | 162 | /* Begin PBXHeadersBuildPhase section */ 163 | D5FBF5371BE65BB500F3CB79 /* Headers */ = { 164 | isa = PBXHeadersBuildPhase; 165 | buildActionMask = 2147483647; 166 | files = ( 167 | D5FBF53E1BE65BB500F3CB79 /* Popsicle.h in Headers */, 168 | ); 169 | runOnlyForDeploymentPostprocessing = 0; 170 | }; 171 | /* End PBXHeadersBuildPhase section */ 172 | 173 | /* Begin PBXNativeTarget section */ 174 | D53E5FE11BEA145F0043DF84 /* PopsicleDemo */ = { 175 | isa = PBXNativeTarget; 176 | buildConfigurationList = D53E5FF11BEA145F0043DF84 /* Build configuration list for PBXNativeTarget "PopsicleDemo" */; 177 | buildPhases = ( 178 | D53E5FDE1BEA145F0043DF84 /* Sources */, 179 | D53E5FDF1BEA145F0043DF84 /* Frameworks */, 180 | D53E5FE01BEA145F0043DF84 /* Resources */, 181 | D593A8E11BEA72E500AFA257 /* Embed Frameworks */, 182 | ); 183 | buildRules = ( 184 | ); 185 | dependencies = ( 186 | D593A8E01BEA72E500AFA257 /* PBXTargetDependency */, 187 | ); 188 | name = PopsicleDemo; 189 | productName = PopsicleDemo; 190 | productReference = D53E5FE21BEA145F0043DF84 /* PopsicleDemo.app */; 191 | productType = "com.apple.product-type.application"; 192 | }; 193 | D5FBF5391BE65BB500F3CB79 /* Popsicle */ = { 194 | isa = PBXNativeTarget; 195 | buildConfigurationList = D5FBF54E1BE65BB600F3CB79 /* Build configuration list for PBXNativeTarget "Popsicle" */; 196 | buildPhases = ( 197 | D5FBF5351BE65BB500F3CB79 /* Sources */, 198 | D5FBF5361BE65BB500F3CB79 /* Frameworks */, 199 | D5FBF5371BE65BB500F3CB79 /* Headers */, 200 | D5FBF5381BE65BB500F3CB79 /* Resources */, 201 | ); 202 | buildRules = ( 203 | ); 204 | dependencies = ( 205 | ); 206 | name = Popsicle; 207 | productName = Popsicle; 208 | productReference = D5FBF53A1BE65BB500F3CB79 /* Popsicle.framework */; 209 | productType = "com.apple.product-type.framework"; 210 | }; 211 | /* End PBXNativeTarget section */ 212 | 213 | /* Begin PBXProject section */ 214 | D5FBF5311BE65BB500F3CB79 /* Project object */ = { 215 | isa = PBXProject; 216 | attributes = { 217 | LastSwiftUpdateCheck = 0710; 218 | LastUpgradeCheck = 0710; 219 | ORGANIZATIONNAME = "David Román Aguirre"; 220 | TargetAttributes = { 221 | D53E5FE11BEA145F0043DF84 = { 222 | CreatedOnToolsVersion = 7.1; 223 | LastSwiftMigration = 0800; 224 | }; 225 | D5FBF5391BE65BB500F3CB79 = { 226 | CreatedOnToolsVersion = 7.1; 227 | LastSwiftMigration = 0800; 228 | }; 229 | }; 230 | }; 231 | buildConfigurationList = D5FBF5341BE65BB500F3CB79 /* Build configuration list for PBXProject "Popsicle" */; 232 | compatibilityVersion = "Xcode 3.2"; 233 | developmentRegion = English; 234 | hasScannedForEncodings = 0; 235 | knownRegions = ( 236 | en, 237 | Base, 238 | ); 239 | mainGroup = D5FBF5301BE65BB500F3CB79; 240 | productRefGroup = D5FBF53B1BE65BB500F3CB79 /* Products */; 241 | projectDirPath = ""; 242 | projectRoot = ""; 243 | targets = ( 244 | D53E5FE11BEA145F0043DF84 /* PopsicleDemo */, 245 | D5FBF5391BE65BB500F3CB79 /* Popsicle */, 246 | ); 247 | }; 248 | /* End PBXProject section */ 249 | 250 | /* Begin PBXResourcesBuildPhase section */ 251 | D53E5FE01BEA145F0043DF84 /* Resources */ = { 252 | isa = PBXResourcesBuildPhase; 253 | buildActionMask = 2147483647; 254 | files = ( 255 | D53E5FEF1BEA145F0043DF84 /* LaunchScreen.storyboard in Resources */, 256 | D53E5FEC1BEA145F0043DF84 /* Assets.xcassets in Resources */, 257 | D53E5FF71BEA16D70043DF84 /* PageViews.xib in Resources */, 258 | ); 259 | runOnlyForDeploymentPostprocessing = 0; 260 | }; 261 | D5FBF5381BE65BB500F3CB79 /* Resources */ = { 262 | isa = PBXResourcesBuildPhase; 263 | buildActionMask = 2147483647; 264 | files = ( 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | /* End PBXResourcesBuildPhase section */ 269 | 270 | /* Begin PBXSourcesBuildPhase section */ 271 | D53E5FDE1BEA145F0043DF84 /* Sources */ = { 272 | isa = PBXSourcesBuildPhase; 273 | buildActionMask = 2147483647; 274 | files = ( 275 | D53E5FE71BEA145F0043DF84 /* ViewController.swift in Sources */, 276 | D53E5FE51BEA145F0043DF84 /* AppDelegate.swift in Sources */, 277 | D53E60051BEA67790043DF84 /* UIView+Utils.swift in Sources */, 278 | D53E60021BEA227D0043DF84 /* DRPageScrollView.m in Sources */, 279 | D53E60011BEA203B0043DF84 /* PageScrollView.swift in Sources */, 280 | ); 281 | runOnlyForDeploymentPostprocessing = 0; 282 | }; 283 | D5FBF5351BE65BB500F3CB79 /* Sources */ = { 284 | isa = PBXSourcesBuildPhase; 285 | buildActionMask = 2147483647; 286 | files = ( 287 | D53E5FDD1BEA13900043DF84 /* Interpolator.swift in Sources */, 288 | D5D6A94C1BEBB85A008E414E /* KeyPath.swift in Sources */, 289 | D53E5FD91BEA12340043DF84 /* EasingFunction.swift in Sources */, 290 | D53B324C1BE65FF800A1820B /* Interpolable.swift in Sources */, 291 | D53E5FDB1BEA13600043DF84 /* Interpolation.swift in Sources */, 292 | ); 293 | runOnlyForDeploymentPostprocessing = 0; 294 | }; 295 | /* End PBXSourcesBuildPhase section */ 296 | 297 | /* Begin PBXTargetDependency section */ 298 | D593A8E01BEA72E500AFA257 /* PBXTargetDependency */ = { 299 | isa = PBXTargetDependency; 300 | target = D5FBF5391BE65BB500F3CB79 /* Popsicle */; 301 | targetProxy = D593A8DF1BEA72E500AFA257 /* PBXContainerItemProxy */; 302 | }; 303 | /* End PBXTargetDependency section */ 304 | 305 | /* Begin PBXVariantGroup section */ 306 | D53E5FED1BEA145F0043DF84 /* LaunchScreen.storyboard */ = { 307 | isa = PBXVariantGroup; 308 | children = ( 309 | D53E5FEE1BEA145F0043DF84 /* Base */, 310 | ); 311 | name = LaunchScreen.storyboard; 312 | sourceTree = ""; 313 | }; 314 | /* End PBXVariantGroup section */ 315 | 316 | /* Begin XCBuildConfiguration section */ 317 | D53E5FF21BEA145F0043DF84 /* Debug */ = { 318 | isa = XCBuildConfiguration; 319 | buildSettings = { 320 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 321 | CLANG_ENABLE_MODULES = YES; 322 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 323 | INFOPLIST_FILE = PopsicleDemo/Info.plist; 324 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 325 | PRODUCT_BUNDLE_IDENTIFIER = me.davidroman.PopsicleDemo; 326 | PRODUCT_NAME = "$(TARGET_NAME)"; 327 | SWIFT_OBJC_BRIDGING_HEADER = "PopsicleDemo/PopsicleDemo-Bridging-Header.h"; 328 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 329 | SWIFT_VERSION = 2.3; 330 | }; 331 | name = Debug; 332 | }; 333 | D53E5FF31BEA145F0043DF84 /* Release */ = { 334 | isa = XCBuildConfiguration; 335 | buildSettings = { 336 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 337 | CLANG_ENABLE_MODULES = YES; 338 | EMBEDDED_CONTENT_CONTAINS_SWIFT = YES; 339 | INFOPLIST_FILE = PopsicleDemo/Info.plist; 340 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 341 | PRODUCT_BUNDLE_IDENTIFIER = me.davidroman.PopsicleDemo; 342 | PRODUCT_NAME = "$(TARGET_NAME)"; 343 | SWIFT_OBJC_BRIDGING_HEADER = "PopsicleDemo/PopsicleDemo-Bridging-Header.h"; 344 | SWIFT_VERSION = 2.3; 345 | }; 346 | name = Release; 347 | }; 348 | D5FBF54C1BE65BB600F3CB79 /* Debug */ = { 349 | isa = XCBuildConfiguration; 350 | buildSettings = { 351 | ALWAYS_SEARCH_USER_PATHS = NO; 352 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 353 | CLANG_CXX_LIBRARY = "libc++"; 354 | CLANG_ENABLE_MODULES = YES; 355 | CLANG_ENABLE_OBJC_ARC = YES; 356 | CLANG_WARN_BOOL_CONVERSION = YES; 357 | CLANG_WARN_CONSTANT_CONVERSION = YES; 358 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 359 | CLANG_WARN_EMPTY_BODY = YES; 360 | CLANG_WARN_ENUM_CONVERSION = YES; 361 | CLANG_WARN_INT_CONVERSION = YES; 362 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 363 | CLANG_WARN_UNREACHABLE_CODE = YES; 364 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 365 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 366 | COPY_PHASE_STRIP = NO; 367 | CURRENT_PROJECT_VERSION = 1; 368 | DEBUG_INFORMATION_FORMAT = dwarf; 369 | ENABLE_STRICT_OBJC_MSGSEND = YES; 370 | ENABLE_TESTABILITY = YES; 371 | GCC_C_LANGUAGE_STANDARD = gnu99; 372 | GCC_DYNAMIC_NO_PIC = NO; 373 | GCC_NO_COMMON_BLOCKS = YES; 374 | GCC_OPTIMIZATION_LEVEL = 0; 375 | GCC_PREPROCESSOR_DEFINITIONS = ( 376 | "DEBUG=1", 377 | "$(inherited)", 378 | ); 379 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 380 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 381 | GCC_WARN_UNDECLARED_SELECTOR = YES; 382 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 383 | GCC_WARN_UNUSED_FUNCTION = YES; 384 | GCC_WARN_UNUSED_VARIABLE = YES; 385 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 386 | MTL_ENABLE_DEBUG_INFO = YES; 387 | ONLY_ACTIVE_ARCH = YES; 388 | SDKROOT = iphoneos; 389 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 390 | TARGETED_DEVICE_FAMILY = "1,2"; 391 | VERSIONING_SYSTEM = "apple-generic"; 392 | VERSION_INFO_PREFIX = ""; 393 | }; 394 | name = Debug; 395 | }; 396 | D5FBF54D1BE65BB600F3CB79 /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ALWAYS_SEARCH_USER_PATHS = NO; 400 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 401 | CLANG_CXX_LIBRARY = "libc++"; 402 | CLANG_ENABLE_MODULES = YES; 403 | CLANG_ENABLE_OBJC_ARC = YES; 404 | CLANG_WARN_BOOL_CONVERSION = YES; 405 | CLANG_WARN_CONSTANT_CONVERSION = YES; 406 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 407 | CLANG_WARN_EMPTY_BODY = YES; 408 | CLANG_WARN_ENUM_CONVERSION = YES; 409 | CLANG_WARN_INT_CONVERSION = YES; 410 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 411 | CLANG_WARN_UNREACHABLE_CODE = YES; 412 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 413 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 414 | COPY_PHASE_STRIP = NO; 415 | CURRENT_PROJECT_VERSION = 1; 416 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 417 | ENABLE_NS_ASSERTIONS = NO; 418 | ENABLE_STRICT_OBJC_MSGSEND = YES; 419 | GCC_C_LANGUAGE_STANDARD = gnu99; 420 | GCC_NO_COMMON_BLOCKS = YES; 421 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 422 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 423 | GCC_WARN_UNDECLARED_SELECTOR = YES; 424 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 425 | GCC_WARN_UNUSED_FUNCTION = YES; 426 | GCC_WARN_UNUSED_VARIABLE = YES; 427 | IPHONEOS_DEPLOYMENT_TARGET = 8.0; 428 | MTL_ENABLE_DEBUG_INFO = NO; 429 | SDKROOT = iphoneos; 430 | TARGETED_DEVICE_FAMILY = "1,2"; 431 | VALIDATE_PRODUCT = YES; 432 | VERSIONING_SYSTEM = "apple-generic"; 433 | VERSION_INFO_PREFIX = ""; 434 | }; 435 | name = Release; 436 | }; 437 | D5FBF54F1BE65BB600F3CB79 /* Debug */ = { 438 | isa = XCBuildConfiguration; 439 | buildSettings = { 440 | CLANG_ENABLE_MODULES = YES; 441 | DEFINES_MODULE = YES; 442 | DYLIB_COMPATIBILITY_VERSION = 1; 443 | DYLIB_CURRENT_VERSION = 1; 444 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 445 | INFOPLIST_FILE = Popsicle/Info.plist; 446 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 447 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 448 | PRODUCT_BUNDLE_IDENTIFIER = me.davidroman.Popsicle; 449 | PRODUCT_NAME = "$(TARGET_NAME)"; 450 | SKIP_INSTALL = YES; 451 | SWIFT_OPTIMIZATION_LEVEL = "-Onone"; 452 | SWIFT_VERSION = 2.3; 453 | }; 454 | name = Debug; 455 | }; 456 | D5FBF5501BE65BB600F3CB79 /* Release */ = { 457 | isa = XCBuildConfiguration; 458 | buildSettings = { 459 | CLANG_ENABLE_MODULES = YES; 460 | DEFINES_MODULE = YES; 461 | DYLIB_COMPATIBILITY_VERSION = 1; 462 | DYLIB_CURRENT_VERSION = 1; 463 | DYLIB_INSTALL_NAME_BASE = "@rpath"; 464 | INFOPLIST_FILE = Popsicle/Info.plist; 465 | INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; 466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 467 | PRODUCT_BUNDLE_IDENTIFIER = me.davidroman.Popsicle; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | SKIP_INSTALL = YES; 470 | SWIFT_VERSION = 2.3; 471 | }; 472 | name = Release; 473 | }; 474 | /* End XCBuildConfiguration section */ 475 | 476 | /* Begin XCConfigurationList section */ 477 | D53E5FF11BEA145F0043DF84 /* Build configuration list for PBXNativeTarget "PopsicleDemo" */ = { 478 | isa = XCConfigurationList; 479 | buildConfigurations = ( 480 | D53E5FF21BEA145F0043DF84 /* Debug */, 481 | D53E5FF31BEA145F0043DF84 /* Release */, 482 | ); 483 | defaultConfigurationIsVisible = 0; 484 | defaultConfigurationName = Release; 485 | }; 486 | D5FBF5341BE65BB500F3CB79 /* Build configuration list for PBXProject "Popsicle" */ = { 487 | isa = XCConfigurationList; 488 | buildConfigurations = ( 489 | D5FBF54C1BE65BB600F3CB79 /* Debug */, 490 | D5FBF54D1BE65BB600F3CB79 /* Release */, 491 | ); 492 | defaultConfigurationIsVisible = 0; 493 | defaultConfigurationName = Release; 494 | }; 495 | D5FBF54E1BE65BB600F3CB79 /* Build configuration list for PBXNativeTarget "Popsicle" */ = { 496 | isa = XCConfigurationList; 497 | buildConfigurations = ( 498 | D5FBF54F1BE65BB600F3CB79 /* Debug */, 499 | D5FBF5501BE65BB600F3CB79 /* Release */, 500 | ); 501 | defaultConfigurationIsVisible = 0; 502 | defaultConfigurationName = Release; 503 | }; 504 | /* End XCConfigurationList section */ 505 | }; 506 | rootObject = D5FBF5311BE65BB500F3CB79 /* Project object */; 507 | } 508 | -------------------------------------------------------------------------------- /Popsicle.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Popsicle.xcodeproj/xcshareddata/xcschemes/Popsicle.xcscheme: -------------------------------------------------------------------------------- 1 | 2 | 5 | 8 | 9 | 15 | 21 | 22 | 23 | 24 | 25 | 30 | 31 | 33 | 39 | 40 | 41 | 42 | 43 | 49 | 50 | 51 | 52 | 53 | 54 | 64 | 65 | 71 | 72 | 73 | 74 | 75 | 76 | 82 | 83 | 89 | 90 | 91 | 92 | 94 | 95 | 98 | 99 | 100 | -------------------------------------------------------------------------------- /Popsicle/EasingFunction.swift: -------------------------------------------------------------------------------- 1 | // 2 | // EasingFunction.swift 3 | // RazzleDazzle 4 | // 5 | // Created by Laura Skelton on 6/15/15. 6 | // Copyright (c) 2015 IFTTT. All rights reserved. 7 | // 8 | 9 | // Ported to Swift from Robert Böhnke's RBBAnimation, original available here: 10 | // 11 | 12 | public typealias EasingFunction = (Progress) -> (Progress) 13 | 14 | public let EasingFunctionLinear: EasingFunction = { t in 15 | return t 16 | } 17 | 18 | public let EasingFunctionEaseInQuad: EasingFunction = { t in 19 | return t * t 20 | } 21 | 22 | public let EasingFunctionEaseOutQuad: EasingFunction = { t in 23 | return t * (2 - t) 24 | } 25 | 26 | public let EasingFunctionEaseInOutQuad: EasingFunction = { t in 27 | if (t < 0.5) { return 2 * t * t } 28 | return -1 + ((4 - (2 * t)) * t) 29 | } 30 | 31 | public let EasingFunctionEaseInCubic: EasingFunction = { t in 32 | return t * t * t 33 | } 34 | 35 | public let EasingFunctionEaseOutCubic: EasingFunction = { t in 36 | return pow(t - 1, 3) + 1 37 | } 38 | 39 | public let EasingFunctionEaseInOutCubic: EasingFunction = { t in 40 | if (t < 0.5) { return 4 * pow(t, 3) } 41 | return ((t - 1) * pow((2 * t) - 2, 2)) + 1 42 | } 43 | 44 | public let EasingFunctionEaseInBounce: EasingFunction = { t in 45 | return 1 - EasingFunctionEaseOutBounce(1 - t) 46 | } 47 | 48 | public let EasingFunctionEaseOutBounce: EasingFunction = { t in 49 | if (t < (4.0 / 11.0)) { 50 | return pow((11.0 / 4.0), 2) * pow(t, 2) 51 | } 52 | 53 | if (t < (8.0 / 11.0)) { 54 | return (3.0 / 4.0) + (pow((11.0 / 4.0), 2) * pow(t - (6.0 / 11.0), 2)) 55 | } 56 | 57 | if (t < (10.0 / 11.0)) { 58 | return (15.0 / 16.0) + (pow((11.0 / 4.0), 2) * pow(t - (9.0 / 11.0), 2)) 59 | } 60 | 61 | return (63.0 / 64.0) + (pow((11.0 / 4.0), 2) * pow(t - (21.0 / 22.0), 2)) 62 | } -------------------------------------------------------------------------------- /Popsicle/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 | 2.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | $(CURRENT_PROJECT_VERSION) 23 | NSPrincipalClass 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /Popsicle/Interpolable.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Interpolable.swift 3 | // Popsicle 4 | // 5 | // Created by David Román Aguirre on 01/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | /// A value from 0 to 1 defining the progress of a certain interpolation between two `Interpolable` values. 10 | public typealias Progress = Double 11 | 12 | /// Defines a common protocol for all interpolable values. 13 | /// 14 | /// Types conforming to this protocol are available to use as a `Interpolation` generic type. 15 | public protocol Interpolable { 16 | typealias ValueType 17 | 18 | /// Defines how an interpolation should be performed between two given values of the type conforming to this protocol. 19 | static func interpolate(from fromValue: ValueType, to toValue: ValueType, withProgress: Progress) -> ValueType 20 | 21 | /// Converts a value to a valid `Foundation` object, if necessary. 22 | static func objectify(value: ValueType) -> AnyObject 23 | } 24 | 25 | extension Bool: Interpolable { 26 | public static func interpolate(from fromValue: Bool, to toValue: Bool, withProgress progress: Progress) -> Bool { 27 | return progress >= 0.5 ? toValue : fromValue 28 | } 29 | 30 | public static func objectify(value: Bool) -> AnyObject { 31 | return NSNumber(bool: value) 32 | } 33 | } 34 | 35 | extension CGFloat: Interpolable { 36 | public static func interpolate(from fromValue: CGFloat, to toValue: CGFloat, withProgress progress: Progress) -> CGFloat { 37 | return fromValue+(toValue-fromValue)*CGFloat(progress) 38 | } 39 | 40 | public static func objectify(value: CGFloat) -> AnyObject { 41 | return NSNumber(double: Double(value)) 42 | } 43 | } 44 | 45 | extension CGPoint: Interpolable { 46 | public static func interpolate(from fromValue: CGPoint, to toValue: CGPoint, withProgress progress: Progress) -> CGPoint { 47 | let x = CGFloat.interpolate(from: fromValue.x, to: toValue.x, withProgress: progress) 48 | let y = CGFloat.interpolate(from: fromValue.y, to: toValue.y, withProgress: progress) 49 | 50 | return CGPointMake(x, y) 51 | } 52 | 53 | public static func objectify(value: CGPoint) -> AnyObject { 54 | return NSValue(CGPoint: value) 55 | } 56 | } 57 | 58 | extension CGSize: Interpolable { 59 | public static func interpolate(from fromValue: CGSize, to toValue: CGSize, withProgress progress: Progress) -> CGSize { 60 | let width = CGFloat.interpolate(from: fromValue.width, to: toValue.width, withProgress: progress) 61 | let height = CGFloat.interpolate(from: fromValue.height, to: toValue.height, withProgress: progress) 62 | 63 | return CGSizeMake(width, height) 64 | } 65 | 66 | public static func objectify(value: CGSize) -> AnyObject { 67 | return NSValue(CGSize: value) 68 | } 69 | } 70 | 71 | extension CGRect: Interpolable { 72 | public static func interpolate(from fromValue: CGRect, to toValue: CGRect, withProgress progress: Progress) -> CGRect { 73 | let origin = CGPoint.interpolate(from: fromValue.origin, to: toValue.origin, withProgress: progress) 74 | let size = CGSize.interpolate(from: fromValue.size, to: toValue.size, withProgress: progress) 75 | 76 | return CGRectMake(origin.x, origin.y, size.width, size.height) 77 | } 78 | 79 | public static func objectify(value: CGRect) -> AnyObject { 80 | return NSValue(CGRect: value) 81 | } 82 | } 83 | 84 | extension CGAffineTransform: Interpolable { 85 | public static func interpolate(from fromValue: CGAffineTransform, to toValue: CGAffineTransform, withProgress progress: Progress) -> CGAffineTransform { 86 | let tx1 = CGAffineTransformGetTranslationX(fromValue) 87 | let tx2 = CGAffineTransformGetTranslationX(toValue) 88 | let tx = CGFloat.interpolate(from: tx1, to: tx2, withProgress: progress) 89 | 90 | let ty1 = CGAffineTransformGetTranslationY(fromValue) 91 | let ty2 = CGAffineTransformGetTranslationY(toValue) 92 | let ty = CGFloat.interpolate(from: ty1, to: ty2, withProgress: progress) 93 | 94 | let sx1 = CGAffineTransformGetScaleX(fromValue) 95 | let sx2 = CGAffineTransformGetScaleX(toValue) 96 | let sx = CGFloat.interpolate(from: sx1, to: sx2, withProgress: progress) 97 | 98 | let sy1 = CGAffineTransformGetScaleY(fromValue) 99 | let sy2 = CGAffineTransformGetScaleY(toValue) 100 | let sy = CGFloat.interpolate(from: sy1, to: sy2, withProgress: progress) 101 | 102 | let deg1 = CGAffineTransformGetRotation(fromValue) 103 | let deg2 = CGAffineTransformGetRotation(toValue) 104 | let deg = CGFloat.interpolate(from: deg1, to: deg2, withProgress: progress) 105 | 106 | return CGAffineTransformMake(tx, ty, sx, sy, deg) 107 | } 108 | 109 | public static func objectify(value: CGAffineTransform) -> AnyObject { 110 | return NSValue(CGAffineTransform: value) 111 | } 112 | } 113 | 114 | /// `CGAffineTransformMake()`, The Right Way™ 115 | /// 116 | /// - parameter tx: translation on x axis. 117 | /// - parameter ty: translation on y axis. 118 | /// - parameter sx: scale factor for width. 119 | /// - parameter sy: scale factor for height. 120 | /// - parameter deg: degrees. 121 | public func CGAffineTransformMake(tx: CGFloat, _ ty: CGFloat, _ sx: CGFloat, _ sy: CGFloat, _ deg: CGFloat) -> CGAffineTransform { 122 | let translationTransform = CGAffineTransformMakeTranslation(tx, ty) 123 | let scaleTransform = CGAffineTransformMakeScale(sx, sy) 124 | let rotationTransform = CGAffineTransformMakeRotation(deg*CGFloat(M_PI_2)/180) 125 | 126 | return CGAffineTransformConcat(CGAffineTransformConcat(translationTransform, scaleTransform), rotationTransform) 127 | } 128 | 129 | func CGAffineTransformGetTranslationX(t: CGAffineTransform) -> CGFloat { return t.tx } 130 | func CGAffineTransformGetTranslationY(t: CGAffineTransform) -> CGFloat { return t.ty } 131 | func CGAffineTransformGetScaleX(t: CGAffineTransform) -> CGFloat { return sqrt(t.a * t.a + t.c * t.c) } 132 | func CGAffineTransformGetScaleY(t: CGAffineTransform) -> CGFloat { return sqrt(t.b * t.b + t.d * t.d) } 133 | func CGAffineTransformGetRotation(t: CGAffineTransform) -> CGFloat { return (atan2(t.b, t.a)*180)/CGFloat(M_PI_2) } 134 | 135 | extension UIColor: Interpolable { 136 | public static func interpolate(from fromValue: UIColor, to toValue: UIColor, withProgress progress: Progress) -> UIColor { 137 | var fromRed: CGFloat = 0 138 | var fromGreen: CGFloat = 0 139 | var fromBlue: CGFloat = 0 140 | var fromAlpha: CGFloat = 0 141 | 142 | var toRed: CGFloat = 0 143 | var toGreen: CGFloat = 0 144 | var toBlue: CGFloat = 0 145 | var toAlpha: CGFloat = 0 146 | 147 | fromValue.getRed(&fromRed, green: &fromGreen, blue: &fromBlue, alpha: &fromAlpha) 148 | toValue.getRed(&toRed, green: &toGreen, blue: &toBlue, alpha: &toAlpha) 149 | 150 | let red = CGFloat.interpolate(from: fromRed, to: toRed, withProgress: progress) 151 | let green = CGFloat.interpolate(from: fromGreen, to: toGreen, withProgress: progress) 152 | let blue = CGFloat.interpolate(from: fromBlue, to: toBlue, withProgress: progress) 153 | let alpha = CGFloat.interpolate(from: fromAlpha, to: toAlpha, withProgress: progress) 154 | 155 | return UIColor(red: red, green: green, blue: blue, alpha: alpha) 156 | } 157 | 158 | public static func objectify(value: UIColor) -> AnyObject { 159 | return value 160 | } 161 | } -------------------------------------------------------------------------------- /Popsicle/Interpolation.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Interpolation.swift 3 | // Popsicle 4 | // 5 | // Created by David Román Aguirre on 04/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | protocol ObjectReferable { 10 | var objectReference: NSObject { get } 11 | } 12 | 13 | protocol Timeable { 14 | func setTime(time: Time) 15 | } 16 | 17 | /// `Interpolation` defines an interpolation which changes some `NSObject` value given by a key path. 18 | public class Interpolation : Equatable, ObjectReferable, Timeable { 19 | let object: NSObject 20 | let keyPath: String 21 | 22 | let originalObject: NSObject 23 | var objectReference: NSObject { return self.originalObject } 24 | 25 | typealias Pole = (T.ValueType, EasingFunction) 26 | private var poles: [Time: Pole] = [:] 27 | 28 | public init(_ object: U, _ keyPath: KeyPath) { 29 | self.originalObject = object 30 | (self.object, self.keyPath) = NSObject.filteredObjectAndKeyPath(withObject: object, andKeyPath: keyPath) 31 | 32 | if !self.object.respondsToSelector(NSSelectorFromString(self.keyPath)) { 33 | assertionFailure("Please make sure the key path \"" + self.keyPath + "\" you're referring to for an object of type <" + NSStringFromClass(self.object.dynamicType) + "> is invalid") 34 | } 35 | } 36 | 37 | /// A convenience initializer with `keyPath` as a `String` parameter. You should try to avoid this method unless absolutely necessary, due to its unsafety. 38 | public convenience init(_ object: NSObject, _ keyPath: String) { 39 | self.init(object, KeyPath(keyPathable: keyPath)) 40 | } 41 | 42 | /// Sets a specific easing function for the interpolation to be performed with for a given time. 43 | /// 44 | /// - parameter easingFunction: the easing function to use. 45 | /// - parameter time: the time where the easing function should be used. 46 | public func setEasingFunction(easingFunction: EasingFunction, forTime time: Time) { 47 | self.poles[time]?.1 = easingFunction 48 | } 49 | 50 | public subscript(time1: Time, rest: Time...) -> T.ValueType? { 51 | get { 52 | assert(poles.count >= 2, "You must specify at least 2 poles for an interpolation to be performed") 53 | if let existingPole = poles[time1] { 54 | return existingPole.0 55 | } else if let timeInterval = poles.keys.sort().elementsAround(time1) { 56 | 57 | guard let fromTime = timeInterval.0 else { 58 | return poles[timeInterval.1!]!.0 59 | } 60 | 61 | guard let toTime = timeInterval.1 else { 62 | return poles[timeInterval.0!]!.0 63 | } 64 | 65 | let easingFunction = poles[fromTime]!.1 66 | let progress = easingFunction(self.progress(fromTime, toTime, time1)) 67 | return T.interpolate(from: poles[fromTime]!.0, to: poles[toTime]!.0, withProgress: progress) 68 | } 69 | 70 | return nil 71 | } 72 | 73 | set { 74 | var times = [time1] 75 | times.appendContentsOf(rest) 76 | for time in times { 77 | poles[time] = (newValue!, EasingFunctionLinear) 78 | } 79 | } 80 | } 81 | 82 | func progress(fromTime: Time, _ toTime: Time, _ currentTime: Time) -> Progress { 83 | let p = (currentTime-fromTime)/(toTime-fromTime) 84 | return min(1, max(0, p)) 85 | } 86 | 87 | func setTime(time: Time) { 88 | self.object.setValue(T.objectify(self[time]!), forKeyPath: self.keyPath) 89 | } 90 | } 91 | 92 | public func ==(lhs: Interpolation, rhs: Interpolation) -> Bool { 93 | return lhs.object == rhs.object && lhs.keyPath == rhs.keyPath 94 | } 95 | 96 | extension Array where Element: Comparable { 97 | func elementPairs() -> [(Element, Element)]? { 98 | if self.count >= 2 { 99 | var elementPairs: [(Element, Element)] = [] 100 | 101 | for (i, e) in self.sort().enumerate() { 102 | if i+1 < self.count { 103 | elementPairs.append((e, self[i+1])) 104 | } 105 | } 106 | 107 | return elementPairs 108 | } 109 | 110 | return nil 111 | } 112 | 113 | func elementsAround(element: Element) -> (Element?, Element?)? { 114 | if let pairs = self.elementPairs() { 115 | 116 | let minElement = pairs.first!.0 117 | let maxElement = pairs.last!.1 118 | 119 | if element < minElement { 120 | return (nil, minElement) 121 | } 122 | 123 | if element > maxElement { 124 | return (maxElement, nil) 125 | } 126 | 127 | for (e1, e2) in pairs where (e1...e2).contains(element) { 128 | return (e1, e2) 129 | } 130 | } 131 | 132 | return nil 133 | } 134 | } -------------------------------------------------------------------------------- /Popsicle/Interpolator.swift: -------------------------------------------------------------------------------- 1 | // 2 | // Interpolator.swift 3 | // Popsicle 4 | // 5 | // Created by David Román Aguirre on 04/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | /// Value type on which interpolation values rely on. 10 | public typealias Time = Double 11 | 12 | /// `Interpolator` collects and coordinates a set of related interpolations through its `time` property. 13 | public class Interpolator { 14 | var interpolations = [Timeable]() 15 | 16 | public init() {} 17 | 18 | public func addInterpolation(interpolation: Interpolation) { 19 | self.interpolations.append(interpolation) 20 | } 21 | 22 | public var time: Time = 0 { 23 | didSet { 24 | self.interpolations.forEach { $0.setTime(self.time) } 25 | } 26 | } 27 | 28 | public func removeInterpolation(interpolation: Interpolation) { 29 | for (index, element) in self.interpolations.enumerate() { 30 | if let interpolation = element as? Interpolation { 31 | if interpolation == interpolation { 32 | self.interpolations.removeAtIndex(index) 33 | } 34 | } 35 | } 36 | } 37 | 38 | /// Removes all interpolations containing the specified object. 39 | public func removeInterpolations(forObject object: NSObject) { 40 | for (index, element) in self.interpolations.enumerate() { 41 | if let interpolation = element as? ObjectReferable { 42 | if interpolation.objectReference == object { 43 | self.interpolations.removeAtIndex(index) 44 | self.removeInterpolations(forObject: object) // Recursivity FTW 45 | return 46 | } 47 | } 48 | } 49 | } 50 | 51 | public func removeAllInterpolations() { 52 | self.interpolations.removeAll() 53 | } 54 | } -------------------------------------------------------------------------------- /Popsicle/KeyPath.swift: -------------------------------------------------------------------------------- 1 | // 2 | // KeyPath.swift 3 | // Popsicle 4 | // 5 | // Created by David Román Aguirre on 04/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | /// `KeyPathable` defines how a value is transformed to a valid `NSObject` key path. 10 | public protocol KeyPathable { 11 | func stringify() -> String 12 | } 13 | 14 | extension String : KeyPathable { 15 | public func stringify() -> String { 16 | return self 17 | } 18 | } 19 | 20 | extension NSLayoutAttribute: KeyPathable { 21 | public func stringify() -> String { 22 | 23 | var type = "UnknownAttribute" 24 | 25 | switch(self) { 26 | case .Left: 27 | type = "Left" 28 | 29 | case .Right: 30 | type = "Right" 31 | 32 | case .Top: 33 | type = "Top" 34 | 35 | case .Bottom: 36 | type = "Bottom" 37 | 38 | case .Leading: 39 | type = "Leading" 40 | 41 | case .Trailing: 42 | type = "Trailing" 43 | 44 | case .Width: 45 | type = "Width" 46 | 47 | case .Height: 48 | type = "Height" 49 | 50 | case .CenterX: 51 | type = "CenterX" 52 | 53 | case .CenterY: 54 | type = "CenterY" 55 | 56 | case .LastBaseline: 57 | type = "Baseline" 58 | 59 | case .FirstBaseline: 60 | type = "FirstBaseline" 61 | 62 | case .LeftMargin: 63 | type = "LeftMargin" 64 | 65 | case .RightMargin: 66 | type = "RightMargin" 67 | 68 | case .TopMargin: 69 | type = "TopMargin" 70 | 71 | case .BottomMargin: 72 | type = "BottomMargin" 73 | 74 | case .LeadingMargin: 75 | type = "LeadingMargin" 76 | 77 | case .TrailingMargin: 78 | type = "TrailingMargin" 79 | 80 | case .CenterXWithinMargins: 81 | type = "CenterXWithinMargins" 82 | 83 | case .CenterYWithinMargins: 84 | type = "CenterYWithinMargins" 85 | 86 | case .NotAnAttribute: 87 | type = "NotAnAttribute" 88 | } 89 | 90 | return "NSLayoutAttribute." + type 91 | } 92 | } 93 | 94 | /// `KeyPath` defines a `NSObject`'s key path, constrained to specific `NSObject` and `Interpolable` types for higher safety. 95 | public struct KeyPath { 96 | let keyPathable: KeyPathable 97 | 98 | public init(keyPathable: KeyPathable) { 99 | self.keyPathable = keyPathable 100 | } 101 | } 102 | 103 | public let alpha = KeyPath(keyPathable: "alpha") 104 | public let backgroundColor = KeyPath(keyPathable: "backgroundColor") 105 | public let barTintColor = KeyPath(keyPathable: "barTintColor") 106 | public let borderColor = KeyPath(keyPathable: "borderColor") 107 | public let borderWidth = KeyPath(keyPathable: "borderWidth") 108 | public let constant = KeyPath(keyPathable: "constant") 109 | public let cornerRadius = KeyPath(keyPathable: "cornerRadius") 110 | public let hidden = KeyPath(keyPathable: "hidden") 111 | public let textColor = KeyPath(keyPathable: "textColor") 112 | public let tintColor = KeyPath(keyPathable: "tintColor") 113 | public let transform = KeyPath(keyPathable: "transform") 114 | 115 | public let baselineConstraint = KeyPath(keyPathable: NSLayoutAttribute.LastBaseline) 116 | public let firstBaselineConstraint = KeyPath(keyPathable: NSLayoutAttribute.FirstBaseline) 117 | 118 | public let topConstraint = KeyPath(keyPathable: NSLayoutAttribute.Top) 119 | public let leftConstraint = KeyPath(keyPathable: NSLayoutAttribute.Left) 120 | public let rightConstraint = KeyPath(keyPathable: NSLayoutAttribute.Right) 121 | public let bottomConstraint = KeyPath(keyPathable: NSLayoutAttribute.Bottom) 122 | public let leadingConstraint = KeyPath(keyPathable: NSLayoutAttribute.Leading) 123 | public let trailingConstraint = KeyPath(keyPathable: NSLayoutAttribute.Trailing) 124 | 125 | public let leftMarginConstraint = KeyPath(keyPathable: NSLayoutAttribute.LeftMargin) 126 | public let rightMarginConstraint = KeyPath(keyPathable: NSLayoutAttribute.RightMargin) 127 | public let topMarginConstraint = KeyPath(keyPathable: NSLayoutAttribute.TopMargin) 128 | public let bottomMarginConstraint = KeyPath(keyPathable: NSLayoutAttribute.BottomMargin) 129 | public let leadingMarginConstraint = KeyPath(keyPathable: NSLayoutAttribute.LeadingMargin) 130 | public let trailingMarginConstraint = KeyPath(keyPathable: NSLayoutAttribute.TrailingMargin) 131 | 132 | public let centerXConstraint = KeyPath(keyPathable: NSLayoutAttribute.CenterX) 133 | public let centerYConstraint = KeyPath(keyPathable: NSLayoutAttribute.CenterY) 134 | 135 | public let centerXWithinMarginsConstraint = KeyPath(keyPathable: NSLayoutAttribute.CenterXWithinMargins) 136 | public let centerYWithinMarginsConstraint = KeyPath(keyPathable: NSLayoutAttribute.CenterYWithinMargins) 137 | 138 | public let widthConstraint = KeyPath(keyPathable: NSLayoutAttribute.Width) 139 | public let heightConstraint = KeyPath(keyPathable: NSLayoutAttribute.Height) 140 | 141 | extension NSObject { 142 | static func filteredObjectAndKeyPath(withObject object: T, andKeyPath keyPath: KeyPath) -> (NSObject, String) { 143 | if let view = object as? UIView, let superview = view.superview, let attribute = keyPath.keyPathable as? NSLayoutAttribute { 144 | 145 | let constrainedView = (attribute == .Width || attribute == .Height) ? view : superview 146 | 147 | for constraint in constrainedView.constraints where 148 | !constraint.isKindOfClass(NSClassFromString("NSContentSizeLayoutConstraint")!) && 149 | ((constraint.firstItem as? NSObject == view && constraint.firstAttribute == attribute) || 150 | (constraint.secondItem as? NSObject == view && constraint.secondAttribute == attribute)) { 151 | return (constraint, constant.keyPathable.stringify()) 152 | } 153 | } 154 | 155 | return (object, keyPath.keyPathable.stringify()) 156 | } 157 | } 158 | -------------------------------------------------------------------------------- /Popsicle/Popsicle.h: -------------------------------------------------------------------------------- 1 | // 2 | // Popsicle.h 3 | // Popsicle 4 | // 5 | // Created by David Román Aguirre on 01/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | @import UIKit; 10 | 11 | //! Project version number for Popsicle. 12 | FOUNDATION_EXPORT double PopsicleVersionNumber; 13 | 14 | //! Project version string for Popsicle. 15 | FOUNDATION_EXPORT const unsigned char PopsicleVersionString[]; 16 | 17 | // In this header, you should import all the public headers of your framework using statements like #import 18 | -------------------------------------------------------------------------------- /PopsicleDemo/AppDelegate.swift: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.swift 3 | // PopsicleDemo 4 | // 5 | // Created by David Román Aguirre on 04/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | @UIApplicationMain 12 | 13 | class AppDelegate: UIResponder, UIApplicationDelegate { 14 | 15 | var window: UIWindow? 16 | 17 | func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { 18 | 19 | self.window = UIWindow(frame: UIScreen.mainScreen().bounds) 20 | self.window?.rootViewController = UINavigationController(rootViewController: ViewController()) 21 | self.window?.makeKeyAndVisible() 22 | 23 | return true 24 | } 25 | } 26 | 27 | -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "size" : "29x29", 5 | "idiom" : "iphone", 6 | "filename" : "Icon-29@2x.png", 7 | "scale" : "2x" 8 | }, 9 | { 10 | "size" : "29x29", 11 | "idiom" : "iphone", 12 | "filename" : "Icon-29@3x.png", 13 | "scale" : "3x" 14 | }, 15 | { 16 | "size" : "40x40", 17 | "idiom" : "iphone", 18 | "filename" : "Icon-40@2x-1.png", 19 | "scale" : "2x" 20 | }, 21 | { 22 | "size" : "40x40", 23 | "idiom" : "iphone", 24 | "filename" : "Icon-40@3x.png", 25 | "scale" : "3x" 26 | }, 27 | { 28 | "size" : "60x60", 29 | "idiom" : "iphone", 30 | "filename" : "Icon-60@2x.png", 31 | "scale" : "2x" 32 | }, 33 | { 34 | "size" : "60x60", 35 | "idiom" : "iphone", 36 | "filename" : "Icon-60@3x.png", 37 | "scale" : "3x" 38 | }, 39 | { 40 | "size" : "29x29", 41 | "idiom" : "ipad", 42 | "filename" : "Icon-29.png", 43 | "scale" : "1x" 44 | }, 45 | { 46 | "size" : "29x29", 47 | "idiom" : "ipad", 48 | "filename" : "Icon-29@2x-1.png", 49 | "scale" : "2x" 50 | }, 51 | { 52 | "size" : "40x40", 53 | "idiom" : "ipad", 54 | "filename" : "Icon-40.png", 55 | "scale" : "1x" 56 | }, 57 | { 58 | "size" : "40x40", 59 | "idiom" : "ipad", 60 | "filename" : "Icon-40@2x.png", 61 | "scale" : "2x" 62 | }, 63 | { 64 | "size" : "76x76", 65 | "idiom" : "ipad", 66 | "filename" : "Icon-76.png", 67 | "scale" : "1x" 68 | }, 69 | { 70 | "size" : "76x76", 71 | "idiom" : "ipad", 72 | "filename" : "Icon-76@2x.png", 73 | "scale" : "2x" 74 | }, 75 | { 76 | "size" : "83.5x83.5", 77 | "idiom" : "ipad", 78 | "filename" : "Icon-83.5@2x.png", 79 | "scale" : "2x" 80 | } 81 | ], 82 | "info" : { 83 | "version" : 1, 84 | "author" : "xcode" 85 | } 86 | } -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-29.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@2x-1.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@2x.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-29@3x.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-40.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x-1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x-1.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@2x.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-40@3x.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@2x.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-60@3x.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-76.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-76@2x.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/AppIcon.appiconset/Icon-83.5@2x.png -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "info" : { 3 | "version" : 1, 4 | "author" : "xcode" 5 | } 6 | } -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/logo.imageset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "universal", 5 | "filename" : "logo.pdf" 6 | } 7 | ], 8 | "info" : { 9 | "version" : 1, 10 | "author" : "xcode" 11 | } 12 | } -------------------------------------------------------------------------------- /PopsicleDemo/Assets.xcassets/logo.imageset/logo.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/davdroman/Popsicle/11c714218bbdb8e31150b97cd0de4b6701ad1d37/PopsicleDemo/Assets.xcassets/logo.imageset/logo.pdf -------------------------------------------------------------------------------- /PopsicleDemo/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 | -------------------------------------------------------------------------------- /PopsicleDemo/DRPageScrollView.h: -------------------------------------------------------------------------------- 1 | // 2 | // DRPageScrollView.h 3 | // DRPageScrollView 4 | // 5 | // Created by David Román Aguirre on 3/4/15. 6 | // Copyright (c) 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | /// The type of block used to define what to display on each page view. 12 | typedef void(^DRPageHandlerBlock)(UIView *pageView); 13 | 14 | @interface DRPageScrollView : UIScrollView 15 | 16 | /// Determines whether page views are reused or not in order to reduce memory consumption. 17 | @property (nonatomic, getter=isPageReuseEnabled) BOOL pageReuseEnabled; 18 | 19 | /// The current page index (starting from 0). 20 | @property (nonatomic, assign) NSInteger currentPage; 21 | 22 | /// The total number of pages in the scroll view. 23 | @property (nonatomic, readonly) NSInteger numberOfPages; 24 | 25 | /** 26 | * Sets up a new page for the scroll view. 27 | * 28 | * @param handler A block that defines what to display on the page. 29 | **/ 30 | - (void)addPageWithHandler:(DRPageHandlerBlock)handler; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /PopsicleDemo/DRPageScrollView.m: -------------------------------------------------------------------------------- 1 | // 2 | // DRPageScrollView.m 3 | // DRPageScrollView 4 | // 5 | // Created by David Román Aguirre on 3/4/15. 6 | // Copyright (c) 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | #import "DRPageScrollView.h" 10 | 11 | @interface DRPageScrollView () { 12 | NSInteger previousPage; 13 | NSInteger instantaneousPreviousPage; 14 | } 15 | 16 | @property (nonatomic, strong) NSArray *pageViews; 17 | @property (nonatomic, strong) NSArray *pageHandlers; 18 | 19 | @end 20 | 21 | @implementation DRPageScrollView 22 | 23 | - (instancetype)init { 24 | if (self = [super init]) { 25 | [self commonInit]; 26 | } 27 | 28 | return self; 29 | } 30 | 31 | - (instancetype)initWithFrame:(CGRect)frame { 32 | if (self = [super initWithFrame:frame]) { 33 | [self commonInit]; 34 | } 35 | 36 | return self; 37 | } 38 | 39 | - (void)commonInit { 40 | previousPage = -1; 41 | self.pagingEnabled = YES; 42 | self.showsHorizontalScrollIndicator = NO; 43 | self.showsVerticalScrollIndicator = NO; 44 | 45 | self.pageViews = [NSMutableArray new]; 46 | self.pageHandlers = [NSArray new]; 47 | } 48 | 49 | - (void)setPageReuseEnabled:(BOOL)pageReuseEnabled { 50 | if (self.numberOfPages > 0) return; 51 | _pageReuseEnabled = pageReuseEnabled; 52 | } 53 | 54 | - (NSInteger)currentPage { 55 | CGPoint presentationLayerContentOffset = [self.layer.presentationLayer bounds].origin; 56 | return MAX(round(presentationLayerContentOffset.x/self.frame.size.width), 0); 57 | } 58 | 59 | - (void)setCurrentPage:(NSInteger)currentPage { 60 | self.contentOffset = CGPointMake(self.frame.size.width*currentPage, self.contentOffset.y); 61 | } 62 | 63 | - (NSInteger)numberOfPages { 64 | return [self.pageHandlers count]; 65 | } 66 | 67 | - (void)addPageWithHandler:(DRPageHandlerBlock)handler { 68 | self.pageHandlers = [self.pageHandlers arrayByAddingObject:handler]; 69 | } 70 | 71 | #pragma mark Pages 72 | 73 | - (BOOL)isAnimating { 74 | return [[self.layer animationKeys] count] != 0; 75 | } 76 | 77 | - (void)setContentOffset:(CGPoint)contentOffset { 78 | [super setContentOffset:contentOffset]; 79 | 80 | if ([self isAnimating]) { 81 | CADisplayLink *displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(didRefreshDisplay:)]; 82 | [displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSDefaultRunLoopMode]; 83 | } else { 84 | [self didScrollToPosition:contentOffset]; 85 | } 86 | } 87 | 88 | - (void)didRefreshDisplay:(CADisplayLink *)displayLink { 89 | if ([self isAnimating]) { 90 | CGPoint presentationLayerContentOffset = [self.layer.presentationLayer bounds].origin; 91 | [self didScrollToPosition:presentationLayerContentOffset]; 92 | } else { 93 | [displayLink invalidate]; 94 | } 95 | } 96 | 97 | - (void)didScrollToPosition:(CGPoint)position { 98 | if (self.numberOfPages == 0 || self.currentPage == previousPage) return; 99 | 100 | if (self.pageReuseEnabled) { 101 | for (UIView *pageView in self.pageViews) { 102 | if (pageView.tag < self.currentPage - 1 || pageView.tag > self.currentPage + 1) { 103 | [self queuePageView:pageView]; 104 | } 105 | } 106 | } 107 | 108 | for (NSInteger i = self.currentPage-1; i <= self.currentPage+1; i++) { 109 | if (i >= 0 && i < self.numberOfPages && ![self pageViewWithTag:i]) { 110 | UIView *pageView = [self dequeuePageView]; 111 | pageView.tag = i; 112 | 113 | DRPageHandlerBlock handler = self.pageHandlers[i]; 114 | handler(pageView); 115 | [self addSubview:pageView]; 116 | 117 | NSInteger pageMultiplier = 2*i+1; // We need an odd multiplier. Any odd number can be expressed as 2n+1. 118 | 119 | NSLayoutConstraint *centerXConstraint = [NSLayoutConstraint constraintWithItem:pageView attribute:NSLayoutAttributeCenterX relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterX multiplier:pageMultiplier constant:0]; 120 | NSLayoutConstraint *centerYConstraint = [NSLayoutConstraint constraintWithItem:pageView attribute:NSLayoutAttributeCenterY relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeCenterY multiplier:1 constant:0]; 121 | NSLayoutConstraint *widthConstraint = [NSLayoutConstraint constraintWithItem:pageView attribute:NSLayoutAttributeWidth relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeWidth multiplier:1 constant:0]; 122 | NSLayoutConstraint *heightConstraint = [NSLayoutConstraint constraintWithItem:pageView attribute:NSLayoutAttributeHeight relatedBy:NSLayoutRelationEqual toItem:self attribute:NSLayoutAttributeHeight multiplier:1 constant:0]; 123 | 124 | [self addConstraints:@[centerXConstraint, centerYConstraint, widthConstraint, heightConstraint]]; // This may lead to vertical orientation support in the future ;) 125 | } 126 | } 127 | 128 | previousPage = self.currentPage; 129 | } 130 | 131 | - (void)queuePageView:(UIView *)pageView { 132 | [pageView removeFromSuperview]; 133 | 134 | for (UIView *sb in pageView.subviews) { 135 | [sb removeFromSuperview]; 136 | } 137 | 138 | pageView.tag = -1; 139 | } 140 | 141 | - (UIView *)dequeuePageView { 142 | for (UIView *pv in self.pageViews) { 143 | if (!pv.superview) { 144 | return pv; 145 | } 146 | } 147 | 148 | UIView *pageView = [UIView new]; 149 | pageView.tag = -1; 150 | pageView.translatesAutoresizingMaskIntoConstraints = NO; 151 | self.pageViews = [self.pageViews arrayByAddingObject:pageView]; 152 | 153 | return pageView; 154 | } 155 | 156 | - (UIView *)pageViewWithTag:(NSInteger)tag { 157 | for (UIView *pageView in self.subviews) { 158 | if (pageView.tag == tag && pageView.class == [UIView class]) { 159 | return pageView; 160 | } 161 | } 162 | 163 | return nil; 164 | } 165 | 166 | #pragma mark Rotation/resize 167 | 168 | - (void)layoutSubviews { 169 | CGFloat neededContentSizeWidth = self.frame.size.width*self.numberOfPages; 170 | 171 | if (self.contentSize.width != neededContentSizeWidth) { 172 | [self refreshDimensions]; 173 | self.currentPage = instantaneousPreviousPage; 174 | } else { 175 | instantaneousPreviousPage = self.currentPage; 176 | } 177 | 178 | [super layoutSubviews]; 179 | } 180 | 181 | - (void)refreshDimensions { 182 | self.contentSize = CGSizeMake(self.frame.size.width*self.numberOfPages, self.frame.size.height); 183 | self.contentInset = UIEdgeInsetsZero; 184 | } 185 | 186 | @end 187 | -------------------------------------------------------------------------------- /PopsicleDemo/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 | Popsicle 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 2.0.1 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIRequiredDeviceCapabilities 28 | 29 | armv7 30 | 31 | UISupportedInterfaceOrientations 32 | 33 | UIInterfaceOrientationPortrait 34 | UIInterfaceOrientationLandscapeLeft 35 | UIInterfaceOrientationLandscapeRight 36 | 37 | UISupportedInterfaceOrientations~ipad 38 | 39 | UIInterfaceOrientationPortrait 40 | UIInterfaceOrientationPortraitUpsideDown 41 | UIInterfaceOrientationLandscapeLeft 42 | UIInterfaceOrientationLandscapeRight 43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /PopsicleDemo/PageScrollView.swift: -------------------------------------------------------------------------------- 1 | // 2 | // PageScrollView.swift 3 | // Popsicle 4 | // 5 | // Created by David Román Aguirre on 04/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | 11 | class FirstPageView: UIView { 12 | @IBOutlet weak var label: UILabel? 13 | @IBOutlet weak var imageView: UIImageView? 14 | } 15 | 16 | class SecondPageView: UIView { 17 | @IBOutlet weak var label: UILabel? 18 | } 19 | 20 | class ThirdPageView: UIView { 21 | @IBOutlet weak var label1: UILabel? 22 | @IBOutlet weak var label2: UILabel? 23 | } 24 | 25 | class FourthPageView: UIView { 26 | @IBOutlet weak var label: UILabel? 27 | } 28 | 29 | class PageScrollView: DRPageScrollView { 30 | let firstPageView: FirstPageView 31 | let secondPageView: SecondPageView 32 | let thirdPageView: ThirdPageView 33 | let fourthPageView: FourthPageView 34 | 35 | override init(frame: CGRect) { 36 | let views = UIView.viewsByClassInNibNamed("PageViews") 37 | self.firstPageView = views["PopsicleDemo.FirstPageView"] as! FirstPageView 38 | self.secondPageView = views["PopsicleDemo.SecondPageView"] as! SecondPageView 39 | self.thirdPageView = views["PopsicleDemo.ThirdPageView"] as! ThirdPageView 40 | self.fourthPageView = views["PopsicleDemo.FourthPageView"] as! FourthPageView 41 | super.init(frame: frame) 42 | } 43 | 44 | required init?(coder aDecoder: NSCoder) { 45 | fatalError("init(coder:) has not been implemented") 46 | } 47 | 48 | override func didMoveToSuperview() { 49 | if self.superview != nil { 50 | for pv in [firstPageView, secondPageView, thirdPageView, fourthPageView] { 51 | self.addPageWithHandler { pageView in 52 | pageView.addSubview(pv) 53 | pv.pinToSuperviewEdges() 54 | } 55 | } 56 | } 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /PopsicleDemo/PageViews.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 82 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | -------------------------------------------------------------------------------- /PopsicleDemo/PopsicleDemo-Bridging-Header.h: -------------------------------------------------------------------------------- 1 | // 2 | // Use this file to import your target's public headers that you would like to expose to Swift. 3 | // 4 | 5 | #import "DRPageScrollView.h" -------------------------------------------------------------------------------- /PopsicleDemo/UIView+Utils.swift: -------------------------------------------------------------------------------- 1 | // 2 | // UIView+Utils.swift 3 | // Popsicle 4 | // 5 | // Created by David Román Aguirre on 04/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | extension UIView { 10 | static func viewsByClassInNibNamed(name: String) -> [String: UIView] { 11 | var viewsByClass = [String: UIView]() 12 | 13 | let nibViews = NSBundle.mainBundle().loadNibNamed(name, owner: self, options: nil) 14 | 15 | for view in nibViews { 16 | if let v = view as? UIView { 17 | viewsByClass[NSStringFromClass(v.dynamicType)] = v 18 | } 19 | } 20 | 21 | return viewsByClass 22 | } 23 | 24 | func pinToSuperviewEdges() { 25 | self.translatesAutoresizingMaskIntoConstraints = false 26 | 27 | for attribute in [.Top, .Left, .Bottom, .Right] as [NSLayoutAttribute] { 28 | let constraint = NSLayoutConstraint(item: self, attribute: attribute, relatedBy: .Equal, toItem: self.superview, attribute: attribute, multiplier: 1, constant: 0) 29 | 30 | self.superview?.addConstraint(constraint) 31 | } 32 | } 33 | } -------------------------------------------------------------------------------- /PopsicleDemo/ViewController.swift: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.swift 3 | // PopsicleDemo 4 | // 5 | // Created by David Román Aguirre on 04/11/15. 6 | // Copyright © 2015 David Román Aguirre. All rights reserved. 7 | // 8 | 9 | import UIKit 10 | import Popsicle 11 | 12 | class ViewController: UIViewController, UIScrollViewDelegate { 13 | 14 | let pageScrollView: PageScrollView 15 | let interpolator: Interpolator 16 | 17 | init() { 18 | self.pageScrollView = PageScrollView(frame: CGRectZero) 19 | self.interpolator = Interpolator() 20 | super.init(nibName: nil, bundle: nil) 21 | } 22 | 23 | required init?(coder aDecoder: NSCoder) { 24 | fatalError("init(coder:) has not been implemented") 25 | } 26 | 27 | override func viewDidLoad() { 28 | super.viewDidLoad() 29 | 30 | self.title = "Popsicle" 31 | self.view.backgroundColor = UIColor.whiteColor() 32 | 33 | self.pageScrollView.delegate = self 34 | self.view.addSubview(self.pageScrollView) 35 | self.pageScrollView.pinToSuperviewEdges() 36 | } 37 | 38 | override func viewDidLayoutSubviews() { 39 | super.viewDidLayoutSubviews() 40 | 41 | self.interpolator.removeAllInterpolations() 42 | 43 | let backgroundColorInterpolation = Interpolation(self.view, backgroundColor) 44 | backgroundColorInterpolation[1, 3] = UIColor.whiteColor() 45 | backgroundColorInterpolation[1.7, 2] = UIColor(red: 254/255, green: 134/255, blue: 44/255, alpha: 1) 46 | self.interpolator.addInterpolation(backgroundColorInterpolation) 47 | 48 | let barTintColorInterpolation = Interpolation(self.navigationController!.navigationBar, barTintColor) 49 | barTintColorInterpolation[1, 3] = UIColor.whiteColor() 50 | barTintColorInterpolation[1.7, 2] = UIColor(red: 244255, green: 219/255, blue: 165/255, alpha: 1) 51 | self.interpolator.addInterpolation(barTintColorInterpolation) 52 | 53 | if let imageView = self.pageScrollView.firstPageView.imageView { 54 | let xInterpolation = Interpolation(imageView, centerXConstraint) 55 | xInterpolation[0] = 0 56 | xInterpolation.setEasingFunction(EasingFunctionEaseInQuad, forTime: 0) 57 | xInterpolation[1] = -self.pageScrollView.frame.width 58 | xInterpolation[2] = -self.pageScrollView.frame.width*2 59 | xInterpolation[3] = -self.pageScrollView.frame.width*3 60 | self.interpolator.addInterpolation(xInterpolation) 61 | 62 | let yInterpolation = Interpolation(imageView, centerYConstraint) 63 | yInterpolation[0] = 0 64 | yInterpolation[1, 2] = -self.pageScrollView.frame.height/2+80 65 | yInterpolation[3] = 0 66 | self.interpolator.addInterpolation(yInterpolation) 67 | 68 | let alphaInterpolation = Interpolation(imageView, alpha) 69 | alphaInterpolation[1] = 1 70 | alphaInterpolation[2] = 0 71 | alphaInterpolation[3] = 0.25 72 | self.interpolator.addInterpolation(alphaInterpolation) 73 | 74 | let transformInterpolation = Interpolation(imageView, transform) 75 | transformInterpolation[0, 1, 2] = CGAffineTransformIdentity 76 | transformInterpolation[0.25] = CGAffineTransformMake(0, 0, 1.1, 1.1, 0) 77 | transformInterpolation[3] = CGAffineTransformMake(0, 0, 1.4, 1.4, 60) 78 | self.interpolator.addInterpolation(transformInterpolation) 79 | } 80 | 81 | if let label1 = self.pageScrollView.firstPageView.label { 82 | let alphaInterpolation = Interpolation(label1, alpha) 83 | alphaInterpolation[0] = 1 84 | alphaInterpolation[0.4] = 0 85 | self.interpolator.addInterpolation(alphaInterpolation) 86 | } 87 | 88 | if let label2 = self.pageScrollView.secondPageView.label { 89 | let scaleInterpolation = Interpolation(label2, transform) 90 | scaleInterpolation[0] = CGAffineTransformMake(0, 0, 0.6, 0.6, 0) 91 | scaleInterpolation[1] = CGAffineTransformMake(0, 0, 1, 1, 0) 92 | self.interpolator.addInterpolation(scaleInterpolation) 93 | 94 | let alphaInterpolation = Interpolation(label2, alpha) 95 | alphaInterpolation[1] = 1 96 | alphaInterpolation[1.7] = 0 97 | self.interpolator.addInterpolation(alphaInterpolation) 98 | } 99 | 100 | if let label3 = self.pageScrollView.thirdPageView.label1, let label4 = self.pageScrollView.thirdPageView.label2 { 101 | let translateInterpolation1 = Interpolation(label3, transform) 102 | translateInterpolation1[1] = CGAffineTransformMake(100, 0, 1, 1, 0) 103 | translateInterpolation1[2] = CGAffineTransformIdentity 104 | translateInterpolation1[3] = CGAffineTransformMake(-100, 0, 1, 1, 0) 105 | self.interpolator.addInterpolation(translateInterpolation1) 106 | 107 | let translateInterpolation2 = Interpolation(label4, transform) 108 | translateInterpolation2[1] = CGAffineTransformMake(300, 0, 1, 1, 0) 109 | translateInterpolation2[2] = CGAffineTransformIdentity 110 | translateInterpolation2[3] = CGAffineTransformMake(-300, 0, 1, 1, 0) 111 | self.interpolator.addInterpolation(translateInterpolation2) 112 | } 113 | } 114 | 115 | func scrollViewDidScroll(scrollView: UIScrollView) { 116 | self.interpolator.time = Double(scrollView.contentOffset.x/scrollView.frame.size.width) 117 | } 118 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | > **THIS PROJECT IS NO LONGER MAINTAINED.** 2 | 3 | --- 4 | 5 |

6 | Popsicle header 7 |

8 | 9 |

10 | Carthage compatible 11 | CocoaPods compatible 12 |

13 | 14 |

15 | GIF 1 16 |

17 | 18 | Popsicle is a Swift framework for creating and managing interpolations of different value types with built-in UIKit support. 19 | 20 | ## Installation 21 | 22 | #### Carthage 23 | 24 | ``` 25 | github "DavdRoman/Popsicle" 26 | ``` 27 | 28 | #### CocoaPods 29 | 30 | ```ruby 31 | pod 'Popsicle' 32 | ``` 33 | 34 | #### Manual 35 | 36 | Drag and copy all files in the [__Popsicle__](Popsicle) folder into your project. 37 | 38 | ## At a glance 39 | 40 | #### Interpolating UIView (or any other NSObject) values 41 | 42 | First, you need an `Interpolator` instance: 43 | 44 | ```swift 45 | let interpolator = Interpolator() 46 | ``` 47 | 48 | Next, you need to add some `Interpolation` instances to your interpolator. In the example below, we are going to interpolate the alpha value of a UIView for times between 0 and 150: 49 | 50 | ```swift 51 | let interpolation = Interpolation(yourView, alpha) 52 | interpolation[0] = 0 53 | interpolation[150] = 1 54 | self.interpolator.addInterpolation(interpolation) 55 | ``` 56 | 57 | Note `alpha` is a built-in `KeyPath` constant. Popsicle offers a nice set of [__UIKit-related KeyPaths__](Popsicle/KeyPath.swift) ready to be used. You may also use a completely custom key path. 58 | 59 | You can also modify the easing function used at a given time: 60 | 61 | ```swift 62 | interpolation.setEasingFunction(EasingFunctionEaseOutQuad, forTime: 0) 63 | ``` 64 | 65 | There's a bunch of [__built-in easing functions__](Popsicle/EasingFunction.swift) to choose from. 66 | 67 | Finally, just make your `interpolator` vary its `time` depending on whatever you want. For example, the content offset of a `UITableView`: 68 | 69 | ```swift 70 | func scrollViewDidScroll(scrollView: UIScrollView) { 71 | interpolator.time = Double(scrollView.contentOffset.y) 72 | } 73 | ``` 74 | 75 | #### Interpolating custom values 76 | 77 | You can declare a value type as interpolable by making it conform to the `Interpolable` protocol. 78 | 79 | As an example, check out how `CGPoint` conforms to `Interpolable`: 80 | 81 | ```swift 82 | extension CGSize: Interpolable { 83 | public static func interpolate(from fromValue: CGSize, to toValue: CGSize, withProgress progress: Progress) -> CGSize { 84 | let width = CGFloat.interpolate(from: fromValue.width, to: toValue.width, withProgress: progress) 85 | let height = CGFloat.interpolate(from: fromValue.height, to: toValue.height, withProgress: progress) 86 | 87 | return CGSizeMake(width, height) 88 | } 89 | 90 | public static func objectify(value: CGSize) -> AnyObject { 91 | return NSValue(CGSize: value) 92 | } 93 | } 94 | ``` 95 | 96 | ## License 97 | 98 | Popsicle is available under the MIT license. 99 | --------------------------------------------------------------------------------