├── .gitignore ├── CHAnimation.gif ├── CHAnimation.podspec ├── CHAnimation.xcodeproj └── project.pbxproj ├── CHAnimation ├── CHAnimation-Info.plist ├── CHAnimation-Prefix.pch ├── CHAnimation │ ├── CHAnimation.h │ ├── CHAnimation.m │ ├── CHAnimationState.h │ ├── CHAnimationState.m │ ├── CHAnimator.h │ └── CHAnimator.m ├── CHAppDelegate.h ├── CHAppDelegate.m ├── CHPopUpMenu.h ├── CHPopUpMenu.m ├── CHViewController.h ├── CHViewController.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── Resources │ ├── background@2x.png │ ├── facebook@2x.png │ ├── googleplus@2x.png │ ├── linkedin@2x.png │ ├── pinterest@2x.png │ ├── plus@2x.png │ ├── skype@2x.png │ ├── tumblr@2x.png │ ├── twitter@2x.png │ └── youtube@2x.png ├── en.lproj │ └── InfoPlist.strings └── main.m ├── CHAnimationTests ├── CHAnimationTests-Info.plist ├── CHAnimationTests.m └── en.lproj │ └── InfoPlist.strings ├── LICENSE └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | # CocoaPods 2 | # 3 | # We recommend against adding the Pods directory to your .gitignore. However 4 | # you should judge for yourself, the pros and cons are mentioned at: 5 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control? 6 | # 7 | # Pods/ 8 | 9 | -------------------------------------------------------------------------------- /CHAnimation.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation.gif -------------------------------------------------------------------------------- /CHAnimation.podspec: -------------------------------------------------------------------------------- 1 | Pod::Spec.new do |s| 2 | s.name = "CHAnimation" 3 | s.version = "0.1" 4 | s.summary = "CHAnimation is a project used to demonstrate how to write your own animation engine, inspired by Facebook Pop." 5 | s.screenshots = "https://raw.github.com/cyndibaby905/CHAnimation/master/CHAnimation.gif" 6 | s.homepage = "https://github.com/cyndibaby905/CHAnimation" 7 | s.license = { :type => 'MIT License', :file => 'LICENSE' } 8 | s.author = { "cyndibaby905" => "hangisnice@gmail.com" } 9 | s.source = { :git => "https://github.com/cyndibaby905/CHAnimation.git", :tag => "0.1" } 10 | s.platform = :ios, '5.0' 11 | s.requires_arc = true 12 | s.source_files = 'CHAnimation/CHAnimation/*.{h,m}' 13 | end -------------------------------------------------------------------------------- /CHAnimation.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 77B4958E192B063E00D8099C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77B4958D192B063E00D8099C /* Foundation.framework */; }; 11 | 77B49590192B063E00D8099C /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77B4958F192B063E00D8099C /* CoreGraphics.framework */; }; 12 | 77B49592192B063E00D8099C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77B49591192B063E00D8099C /* UIKit.framework */; }; 13 | 77B49598192B063E00D8099C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 77B49596192B063E00D8099C /* InfoPlist.strings */; }; 14 | 77B4959A192B063E00D8099C /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B49599192B063E00D8099C /* main.m */; }; 15 | 77B4959E192B063E00D8099C /* CHAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B4959D192B063E00D8099C /* CHAppDelegate.m */; }; 16 | 77B495A7192B063E00D8099C /* CHViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B495A6192B063E00D8099C /* CHViewController.m */; }; 17 | 77B495A9192B063E00D8099C /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 77B495A8192B063E00D8099C /* Images.xcassets */; }; 18 | 77B495B0192B063E00D8099C /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77B495AF192B063E00D8099C /* XCTest.framework */; }; 19 | 77B495B1192B063E00D8099C /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77B4958D192B063E00D8099C /* Foundation.framework */; }; 20 | 77B495B2192B063E00D8099C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 77B49591192B063E00D8099C /* UIKit.framework */; }; 21 | 77B495BA192B063E00D8099C /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 77B495B8192B063E00D8099C /* InfoPlist.strings */; }; 22 | 77B495BC192B063E00D8099C /* CHAnimationTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B495BB192B063E00D8099C /* CHAnimationTests.m */; }; 23 | 77B495C8192B070E00D8099C /* CHAnimator.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B495C7192B070E00D8099C /* CHAnimator.m */; }; 24 | 77B495CB192B080200D8099C /* CHAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B495CA192B080200D8099C /* CHAnimation.m */; }; 25 | 77B495CE192B131300D8099C /* CHAnimationState.m in Sources */ = {isa = PBXBuildFile; fileRef = 77B495CD192B131300D8099C /* CHAnimationState.m */; }; 26 | 77B58A5B192E11F3006AA8FE /* background@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77B58A5A192E11F3006AA8FE /* background@2x.png */; }; 27 | 77F1186A192D9E9B0038F5AA /* CHPopUpMenu.m in Sources */ = {isa = PBXBuildFile; fileRef = 77F11869192D9E9B0038F5AA /* CHPopUpMenu.m */; }; 28 | 77F1188D192DCE290038F5AA /* facebook@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F11884192DCE290038F5AA /* facebook@2x.png */; }; 29 | 77F1188E192DCE290038F5AA /* googleplus@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F11885192DCE290038F5AA /* googleplus@2x.png */; }; 30 | 77F1188F192DCE290038F5AA /* linkedin@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F11886192DCE290038F5AA /* linkedin@2x.png */; }; 31 | 77F11890192DCE290038F5AA /* pinterest@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F11887192DCE290038F5AA /* pinterest@2x.png */; }; 32 | 77F11891192DCE290038F5AA /* plus@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F11888192DCE290038F5AA /* plus@2x.png */; }; 33 | 77F11892192DCE290038F5AA /* skype@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F11889192DCE290038F5AA /* skype@2x.png */; }; 34 | 77F11893192DCE290038F5AA /* tumblr@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F1188A192DCE290038F5AA /* tumblr@2x.png */; }; 35 | 77F11894192DCE290038F5AA /* twitter@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F1188B192DCE290038F5AA /* twitter@2x.png */; }; 36 | 77F11895192DCE290038F5AA /* youtube@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 77F1188C192DCE290038F5AA /* youtube@2x.png */; }; 37 | /* End PBXBuildFile section */ 38 | 39 | /* Begin PBXContainerItemProxy section */ 40 | 77B495B3192B063E00D8099C /* PBXContainerItemProxy */ = { 41 | isa = PBXContainerItemProxy; 42 | containerPortal = 77B49582192B063E00D8099C /* Project object */; 43 | proxyType = 1; 44 | remoteGlobalIDString = 77B49589192B063E00D8099C; 45 | remoteInfo = CHAnimation; 46 | }; 47 | /* End PBXContainerItemProxy section */ 48 | 49 | /* Begin PBXFileReference section */ 50 | 77B4958A192B063E00D8099C /* CHAnimation.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = CHAnimation.app; sourceTree = BUILT_PRODUCTS_DIR; }; 51 | 77B4958D192B063E00D8099C /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 52 | 77B4958F192B063E00D8099C /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 53 | 77B49591192B063E00D8099C /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 54 | 77B49595192B063E00D8099C /* CHAnimation-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CHAnimation-Info.plist"; sourceTree = ""; }; 55 | 77B49597192B063E00D8099C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 56 | 77B49599192B063E00D8099C /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 57 | 77B4959B192B063E00D8099C /* CHAnimation-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "CHAnimation-Prefix.pch"; sourceTree = ""; }; 58 | 77B4959C192B063E00D8099C /* CHAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHAppDelegate.h; sourceTree = ""; }; 59 | 77B4959D192B063E00D8099C /* CHAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CHAppDelegate.m; sourceTree = ""; }; 60 | 77B495A5192B063E00D8099C /* CHViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = CHViewController.h; sourceTree = ""; }; 61 | 77B495A6192B063E00D8099C /* CHViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CHViewController.m; sourceTree = ""; }; 62 | 77B495A8192B063E00D8099C /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 63 | 77B495AE192B063E00D8099C /* CHAnimationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = CHAnimationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 64 | 77B495AF192B063E00D8099C /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 65 | 77B495B7192B063E00D8099C /* CHAnimationTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "CHAnimationTests-Info.plist"; sourceTree = ""; }; 66 | 77B495B9192B063E00D8099C /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 67 | 77B495BB192B063E00D8099C /* CHAnimationTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = CHAnimationTests.m; sourceTree = ""; }; 68 | 77B495C6192B070E00D8099C /* CHAnimator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHAnimator.h; sourceTree = ""; }; 69 | 77B495C7192B070E00D8099C /* CHAnimator.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CHAnimator.m; sourceTree = ""; }; 70 | 77B495C9192B080200D8099C /* CHAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHAnimation.h; sourceTree = ""; }; 71 | 77B495CA192B080200D8099C /* CHAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CHAnimation.m; sourceTree = ""; }; 72 | 77B495CC192B131300D8099C /* CHAnimationState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHAnimationState.h; sourceTree = ""; }; 73 | 77B495CD192B131300D8099C /* CHAnimationState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CHAnimationState.m; sourceTree = ""; }; 74 | 77B58A5A192E11F3006AA8FE /* background@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "background@2x.png"; sourceTree = ""; }; 75 | 77F11868192D9E9B0038F5AA /* CHPopUpMenu.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CHPopUpMenu.h; sourceTree = ""; }; 76 | 77F11869192D9E9B0038F5AA /* CHPopUpMenu.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CHPopUpMenu.m; sourceTree = ""; }; 77 | 77F11884192DCE290038F5AA /* facebook@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "facebook@2x.png"; sourceTree = ""; }; 78 | 77F11885192DCE290038F5AA /* googleplus@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "googleplus@2x.png"; sourceTree = ""; }; 79 | 77F11886192DCE290038F5AA /* linkedin@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "linkedin@2x.png"; sourceTree = ""; }; 80 | 77F11887192DCE290038F5AA /* pinterest@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "pinterest@2x.png"; sourceTree = ""; }; 81 | 77F11888192DCE290038F5AA /* plus@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "plus@2x.png"; sourceTree = ""; }; 82 | 77F11889192DCE290038F5AA /* skype@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "skype@2x.png"; sourceTree = ""; }; 83 | 77F1188A192DCE290038F5AA /* tumblr@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "tumblr@2x.png"; sourceTree = ""; }; 84 | 77F1188B192DCE290038F5AA /* twitter@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "twitter@2x.png"; sourceTree = ""; }; 85 | 77F1188C192DCE290038F5AA /* youtube@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = "youtube@2x.png"; sourceTree = ""; }; 86 | /* End PBXFileReference section */ 87 | 88 | /* Begin PBXFrameworksBuildPhase section */ 89 | 77B49587192B063E00D8099C /* Frameworks */ = { 90 | isa = PBXFrameworksBuildPhase; 91 | buildActionMask = 2147483647; 92 | files = ( 93 | 77B49590192B063E00D8099C /* CoreGraphics.framework in Frameworks */, 94 | 77B49592192B063E00D8099C /* UIKit.framework in Frameworks */, 95 | 77B4958E192B063E00D8099C /* Foundation.framework in Frameworks */, 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | 77B495AB192B063E00D8099C /* Frameworks */ = { 100 | isa = PBXFrameworksBuildPhase; 101 | buildActionMask = 2147483647; 102 | files = ( 103 | 77B495B0192B063E00D8099C /* XCTest.framework in Frameworks */, 104 | 77B495B2192B063E00D8099C /* UIKit.framework in Frameworks */, 105 | 77B495B1192B063E00D8099C /* Foundation.framework in Frameworks */, 106 | ); 107 | runOnlyForDeploymentPostprocessing = 0; 108 | }; 109 | /* End PBXFrameworksBuildPhase section */ 110 | 111 | /* Begin PBXGroup section */ 112 | 77B49581192B063E00D8099C = { 113 | isa = PBXGroup; 114 | children = ( 115 | 77B49593192B063E00D8099C /* CHAnimation */, 116 | 77B495B5192B063E00D8099C /* CHAnimationTests */, 117 | 77B4958C192B063E00D8099C /* Frameworks */, 118 | 77B4958B192B063E00D8099C /* Products */, 119 | ); 120 | sourceTree = ""; 121 | }; 122 | 77B4958B192B063E00D8099C /* Products */ = { 123 | isa = PBXGroup; 124 | children = ( 125 | 77B4958A192B063E00D8099C /* CHAnimation.app */, 126 | 77B495AE192B063E00D8099C /* CHAnimationTests.xctest */, 127 | ); 128 | name = Products; 129 | sourceTree = ""; 130 | }; 131 | 77B4958C192B063E00D8099C /* Frameworks */ = { 132 | isa = PBXGroup; 133 | children = ( 134 | 77B4958D192B063E00D8099C /* Foundation.framework */, 135 | 77B4958F192B063E00D8099C /* CoreGraphics.framework */, 136 | 77B49591192B063E00D8099C /* UIKit.framework */, 137 | 77B495AF192B063E00D8099C /* XCTest.framework */, 138 | ); 139 | name = Frameworks; 140 | sourceTree = ""; 141 | }; 142 | 77B49593192B063E00D8099C /* CHAnimation */ = { 143 | isa = PBXGroup; 144 | children = ( 145 | 77F11883192DCE290038F5AA /* Resources */, 146 | 77B495C5192B070E00D8099C /* CHAnimation */, 147 | 77B4959C192B063E00D8099C /* CHAppDelegate.h */, 148 | 77B4959D192B063E00D8099C /* CHAppDelegate.m */, 149 | 77F11868192D9E9B0038F5AA /* CHPopUpMenu.h */, 150 | 77F11869192D9E9B0038F5AA /* CHPopUpMenu.m */, 151 | 77B495A5192B063E00D8099C /* CHViewController.h */, 152 | 77B495A6192B063E00D8099C /* CHViewController.m */, 153 | 77B495A8192B063E00D8099C /* Images.xcassets */, 154 | 77B49594192B063E00D8099C /* Supporting Files */, 155 | ); 156 | path = CHAnimation; 157 | sourceTree = ""; 158 | }; 159 | 77B49594192B063E00D8099C /* Supporting Files */ = { 160 | isa = PBXGroup; 161 | children = ( 162 | 77B49595192B063E00D8099C /* CHAnimation-Info.plist */, 163 | 77B49596192B063E00D8099C /* InfoPlist.strings */, 164 | 77B49599192B063E00D8099C /* main.m */, 165 | 77B4959B192B063E00D8099C /* CHAnimation-Prefix.pch */, 166 | ); 167 | name = "Supporting Files"; 168 | sourceTree = ""; 169 | }; 170 | 77B495B5192B063E00D8099C /* CHAnimationTests */ = { 171 | isa = PBXGroup; 172 | children = ( 173 | 77B495BB192B063E00D8099C /* CHAnimationTests.m */, 174 | 77B495B6192B063E00D8099C /* Supporting Files */, 175 | ); 176 | path = CHAnimationTests; 177 | sourceTree = ""; 178 | }; 179 | 77B495B6192B063E00D8099C /* Supporting Files */ = { 180 | isa = PBXGroup; 181 | children = ( 182 | 77B495B7192B063E00D8099C /* CHAnimationTests-Info.plist */, 183 | 77B495B8192B063E00D8099C /* InfoPlist.strings */, 184 | ); 185 | name = "Supporting Files"; 186 | sourceTree = ""; 187 | }; 188 | 77B495C5192B070E00D8099C /* CHAnimation */ = { 189 | isa = PBXGroup; 190 | children = ( 191 | 77B495C6192B070E00D8099C /* CHAnimator.h */, 192 | 77B495C7192B070E00D8099C /* CHAnimator.m */, 193 | 77B495C9192B080200D8099C /* CHAnimation.h */, 194 | 77B495CA192B080200D8099C /* CHAnimation.m */, 195 | 77B495CC192B131300D8099C /* CHAnimationState.h */, 196 | 77B495CD192B131300D8099C /* CHAnimationState.m */, 197 | ); 198 | path = CHAnimation; 199 | sourceTree = ""; 200 | }; 201 | 77F11883192DCE290038F5AA /* Resources */ = { 202 | isa = PBXGroup; 203 | children = ( 204 | 77B58A5A192E11F3006AA8FE /* background@2x.png */, 205 | 77F11884192DCE290038F5AA /* facebook@2x.png */, 206 | 77F11885192DCE290038F5AA /* googleplus@2x.png */, 207 | 77F11886192DCE290038F5AA /* linkedin@2x.png */, 208 | 77F11887192DCE290038F5AA /* pinterest@2x.png */, 209 | 77F11888192DCE290038F5AA /* plus@2x.png */, 210 | 77F11889192DCE290038F5AA /* skype@2x.png */, 211 | 77F1188A192DCE290038F5AA /* tumblr@2x.png */, 212 | 77F1188B192DCE290038F5AA /* twitter@2x.png */, 213 | 77F1188C192DCE290038F5AA /* youtube@2x.png */, 214 | ); 215 | path = Resources; 216 | sourceTree = ""; 217 | }; 218 | /* End PBXGroup section */ 219 | 220 | /* Begin PBXNativeTarget section */ 221 | 77B49589192B063E00D8099C /* CHAnimation */ = { 222 | isa = PBXNativeTarget; 223 | buildConfigurationList = 77B495BF192B063E00D8099C /* Build configuration list for PBXNativeTarget "CHAnimation" */; 224 | buildPhases = ( 225 | 77B49586192B063E00D8099C /* Sources */, 226 | 77B49587192B063E00D8099C /* Frameworks */, 227 | 77B49588192B063E00D8099C /* Resources */, 228 | ); 229 | buildRules = ( 230 | ); 231 | dependencies = ( 232 | ); 233 | name = CHAnimation; 234 | productName = CHAnimation; 235 | productReference = 77B4958A192B063E00D8099C /* CHAnimation.app */; 236 | productType = "com.apple.product-type.application"; 237 | }; 238 | 77B495AD192B063E00D8099C /* CHAnimationTests */ = { 239 | isa = PBXNativeTarget; 240 | buildConfigurationList = 77B495C2192B063E00D8099C /* Build configuration list for PBXNativeTarget "CHAnimationTests" */; 241 | buildPhases = ( 242 | 77B495AA192B063E00D8099C /* Sources */, 243 | 77B495AB192B063E00D8099C /* Frameworks */, 244 | 77B495AC192B063E00D8099C /* Resources */, 245 | ); 246 | buildRules = ( 247 | ); 248 | dependencies = ( 249 | 77B495B4192B063E00D8099C /* PBXTargetDependency */, 250 | ); 251 | name = CHAnimationTests; 252 | productName = CHAnimationTests; 253 | productReference = 77B495AE192B063E00D8099C /* CHAnimationTests.xctest */; 254 | productType = "com.apple.product-type.bundle.unit-test"; 255 | }; 256 | /* End PBXNativeTarget section */ 257 | 258 | /* Begin PBXProject section */ 259 | 77B49582192B063E00D8099C /* Project object */ = { 260 | isa = PBXProject; 261 | attributes = { 262 | CLASSPREFIX = CH; 263 | LastUpgradeCheck = 0510; 264 | ORGANIZATIONNAME = hangchen; 265 | TargetAttributes = { 266 | 77B495AD192B063E00D8099C = { 267 | TestTargetID = 77B49589192B063E00D8099C; 268 | }; 269 | }; 270 | }; 271 | buildConfigurationList = 77B49585192B063E00D8099C /* Build configuration list for PBXProject "CHAnimation" */; 272 | compatibilityVersion = "Xcode 3.2"; 273 | developmentRegion = English; 274 | hasScannedForEncodings = 0; 275 | knownRegions = ( 276 | en, 277 | Base, 278 | ); 279 | mainGroup = 77B49581192B063E00D8099C; 280 | productRefGroup = 77B4958B192B063E00D8099C /* Products */; 281 | projectDirPath = ""; 282 | projectRoot = ""; 283 | targets = ( 284 | 77B49589192B063E00D8099C /* CHAnimation */, 285 | 77B495AD192B063E00D8099C /* CHAnimationTests */, 286 | ); 287 | }; 288 | /* End PBXProject section */ 289 | 290 | /* Begin PBXResourcesBuildPhase section */ 291 | 77B49588192B063E00D8099C /* Resources */ = { 292 | isa = PBXResourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 77F11894192DCE290038F5AA /* twitter@2x.png in Resources */, 296 | 77B495A9192B063E00D8099C /* Images.xcassets in Resources */, 297 | 77F1188D192DCE290038F5AA /* facebook@2x.png in Resources */, 298 | 77F11893192DCE290038F5AA /* tumblr@2x.png in Resources */, 299 | 77F1188F192DCE290038F5AA /* linkedin@2x.png in Resources */, 300 | 77F11891192DCE290038F5AA /* plus@2x.png in Resources */, 301 | 77B49598192B063E00D8099C /* InfoPlist.strings in Resources */, 302 | 77F11895192DCE290038F5AA /* youtube@2x.png in Resources */, 303 | 77F11892192DCE290038F5AA /* skype@2x.png in Resources */, 304 | 77F1188E192DCE290038F5AA /* googleplus@2x.png in Resources */, 305 | 77B58A5B192E11F3006AA8FE /* background@2x.png in Resources */, 306 | 77F11890192DCE290038F5AA /* pinterest@2x.png in Resources */, 307 | ); 308 | runOnlyForDeploymentPostprocessing = 0; 309 | }; 310 | 77B495AC192B063E00D8099C /* Resources */ = { 311 | isa = PBXResourcesBuildPhase; 312 | buildActionMask = 2147483647; 313 | files = ( 314 | 77B495BA192B063E00D8099C /* InfoPlist.strings in Resources */, 315 | ); 316 | runOnlyForDeploymentPostprocessing = 0; 317 | }; 318 | /* End PBXResourcesBuildPhase section */ 319 | 320 | /* Begin PBXSourcesBuildPhase section */ 321 | 77B49586192B063E00D8099C /* Sources */ = { 322 | isa = PBXSourcesBuildPhase; 323 | buildActionMask = 2147483647; 324 | files = ( 325 | 77F1186A192D9E9B0038F5AA /* CHPopUpMenu.m in Sources */, 326 | 77B4959A192B063E00D8099C /* main.m in Sources */, 327 | 77B495C8192B070E00D8099C /* CHAnimator.m in Sources */, 328 | 77B4959E192B063E00D8099C /* CHAppDelegate.m in Sources */, 329 | 77B495CE192B131300D8099C /* CHAnimationState.m in Sources */, 330 | 77B495A7192B063E00D8099C /* CHViewController.m in Sources */, 331 | 77B495CB192B080200D8099C /* CHAnimation.m in Sources */, 332 | ); 333 | runOnlyForDeploymentPostprocessing = 0; 334 | }; 335 | 77B495AA192B063E00D8099C /* Sources */ = { 336 | isa = PBXSourcesBuildPhase; 337 | buildActionMask = 2147483647; 338 | files = ( 339 | 77B495BC192B063E00D8099C /* CHAnimationTests.m in Sources */, 340 | ); 341 | runOnlyForDeploymentPostprocessing = 0; 342 | }; 343 | /* End PBXSourcesBuildPhase section */ 344 | 345 | /* Begin PBXTargetDependency section */ 346 | 77B495B4192B063E00D8099C /* PBXTargetDependency */ = { 347 | isa = PBXTargetDependency; 348 | target = 77B49589192B063E00D8099C /* CHAnimation */; 349 | targetProxy = 77B495B3192B063E00D8099C /* PBXContainerItemProxy */; 350 | }; 351 | /* End PBXTargetDependency section */ 352 | 353 | /* Begin PBXVariantGroup section */ 354 | 77B49596192B063E00D8099C /* InfoPlist.strings */ = { 355 | isa = PBXVariantGroup; 356 | children = ( 357 | 77B49597192B063E00D8099C /* en */, 358 | ); 359 | name = InfoPlist.strings; 360 | sourceTree = ""; 361 | }; 362 | 77B495B8192B063E00D8099C /* InfoPlist.strings */ = { 363 | isa = PBXVariantGroup; 364 | children = ( 365 | 77B495B9192B063E00D8099C /* en */, 366 | ); 367 | name = InfoPlist.strings; 368 | sourceTree = ""; 369 | }; 370 | /* End PBXVariantGroup section */ 371 | 372 | /* Begin XCBuildConfiguration section */ 373 | 77B495BD192B063E00D8099C /* Debug */ = { 374 | isa = XCBuildConfiguration; 375 | buildSettings = { 376 | ALWAYS_SEARCH_USER_PATHS = NO; 377 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 378 | CLANG_CXX_LIBRARY = "libc++"; 379 | CLANG_ENABLE_MODULES = YES; 380 | CLANG_ENABLE_OBJC_ARC = YES; 381 | CLANG_WARN_BOOL_CONVERSION = YES; 382 | CLANG_WARN_CONSTANT_CONVERSION = YES; 383 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 384 | CLANG_WARN_EMPTY_BODY = YES; 385 | CLANG_WARN_ENUM_CONVERSION = YES; 386 | CLANG_WARN_INT_CONVERSION = YES; 387 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 388 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 389 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 390 | COPY_PHASE_STRIP = NO; 391 | GCC_C_LANGUAGE_STANDARD = gnu99; 392 | GCC_DYNAMIC_NO_PIC = NO; 393 | GCC_OPTIMIZATION_LEVEL = 0; 394 | GCC_PREPROCESSOR_DEFINITIONS = ( 395 | "DEBUG=1", 396 | "$(inherited)", 397 | ); 398 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 399 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 400 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 401 | GCC_WARN_UNDECLARED_SELECTOR = YES; 402 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 403 | GCC_WARN_UNUSED_FUNCTION = YES; 404 | GCC_WARN_UNUSED_VARIABLE = YES; 405 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 406 | ONLY_ACTIVE_ARCH = YES; 407 | SDKROOT = iphoneos; 408 | TARGETED_DEVICE_FAMILY = "1,2"; 409 | }; 410 | name = Debug; 411 | }; 412 | 77B495BE192B063E00D8099C /* Release */ = { 413 | isa = XCBuildConfiguration; 414 | buildSettings = { 415 | ALWAYS_SEARCH_USER_PATHS = NO; 416 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 417 | CLANG_CXX_LIBRARY = "libc++"; 418 | CLANG_ENABLE_MODULES = YES; 419 | CLANG_ENABLE_OBJC_ARC = YES; 420 | CLANG_WARN_BOOL_CONVERSION = YES; 421 | CLANG_WARN_CONSTANT_CONVERSION = YES; 422 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 423 | CLANG_WARN_EMPTY_BODY = YES; 424 | CLANG_WARN_ENUM_CONVERSION = YES; 425 | CLANG_WARN_INT_CONVERSION = YES; 426 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 427 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 428 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 429 | COPY_PHASE_STRIP = YES; 430 | ENABLE_NS_ASSERTIONS = NO; 431 | GCC_C_LANGUAGE_STANDARD = gnu99; 432 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 433 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 434 | GCC_WARN_UNDECLARED_SELECTOR = YES; 435 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 436 | GCC_WARN_UNUSED_FUNCTION = YES; 437 | GCC_WARN_UNUSED_VARIABLE = YES; 438 | IPHONEOS_DEPLOYMENT_TARGET = 7.1; 439 | SDKROOT = iphoneos; 440 | TARGETED_DEVICE_FAMILY = "1,2"; 441 | VALIDATE_PRODUCT = YES; 442 | }; 443 | name = Release; 444 | }; 445 | 77B495C0192B063E00D8099C /* Debug */ = { 446 | isa = XCBuildConfiguration; 447 | buildSettings = { 448 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 449 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 450 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 451 | GCC_PREFIX_HEADER = "CHAnimation/CHAnimation-Prefix.pch"; 452 | INFOPLIST_FILE = "CHAnimation/CHAnimation-Info.plist"; 453 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 454 | PRODUCT_NAME = "$(TARGET_NAME)"; 455 | WRAPPER_EXTENSION = app; 456 | }; 457 | name = Debug; 458 | }; 459 | 77B495C1192B063E00D8099C /* Release */ = { 460 | isa = XCBuildConfiguration; 461 | buildSettings = { 462 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 463 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 464 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 465 | GCC_PREFIX_HEADER = "CHAnimation/CHAnimation-Prefix.pch"; 466 | INFOPLIST_FILE = "CHAnimation/CHAnimation-Info.plist"; 467 | IPHONEOS_DEPLOYMENT_TARGET = 6.0; 468 | PRODUCT_NAME = "$(TARGET_NAME)"; 469 | WRAPPER_EXTENSION = app; 470 | }; 471 | name = Release; 472 | }; 473 | 77B495C3192B063E00D8099C /* Debug */ = { 474 | isa = XCBuildConfiguration; 475 | buildSettings = { 476 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CHAnimation.app/CHAnimation"; 477 | FRAMEWORK_SEARCH_PATHS = ( 478 | "$(SDKROOT)/Developer/Library/Frameworks", 479 | "$(inherited)", 480 | "$(DEVELOPER_FRAMEWORKS_DIR)", 481 | ); 482 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 483 | GCC_PREFIX_HEADER = "CHAnimation/CHAnimation-Prefix.pch"; 484 | GCC_PREPROCESSOR_DEFINITIONS = ( 485 | "DEBUG=1", 486 | "$(inherited)", 487 | ); 488 | INFOPLIST_FILE = "CHAnimationTests/CHAnimationTests-Info.plist"; 489 | PRODUCT_NAME = "$(TARGET_NAME)"; 490 | TEST_HOST = "$(BUNDLE_LOADER)"; 491 | WRAPPER_EXTENSION = xctest; 492 | }; 493 | name = Debug; 494 | }; 495 | 77B495C4192B063E00D8099C /* Release */ = { 496 | isa = XCBuildConfiguration; 497 | buildSettings = { 498 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/CHAnimation.app/CHAnimation"; 499 | FRAMEWORK_SEARCH_PATHS = ( 500 | "$(SDKROOT)/Developer/Library/Frameworks", 501 | "$(inherited)", 502 | "$(DEVELOPER_FRAMEWORKS_DIR)", 503 | ); 504 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 505 | GCC_PREFIX_HEADER = "CHAnimation/CHAnimation-Prefix.pch"; 506 | INFOPLIST_FILE = "CHAnimationTests/CHAnimationTests-Info.plist"; 507 | PRODUCT_NAME = "$(TARGET_NAME)"; 508 | TEST_HOST = "$(BUNDLE_LOADER)"; 509 | WRAPPER_EXTENSION = xctest; 510 | }; 511 | name = Release; 512 | }; 513 | /* End XCBuildConfiguration section */ 514 | 515 | /* Begin XCConfigurationList section */ 516 | 77B49585192B063E00D8099C /* Build configuration list for PBXProject "CHAnimation" */ = { 517 | isa = XCConfigurationList; 518 | buildConfigurations = ( 519 | 77B495BD192B063E00D8099C /* Debug */, 520 | 77B495BE192B063E00D8099C /* Release */, 521 | ); 522 | defaultConfigurationIsVisible = 0; 523 | defaultConfigurationName = Release; 524 | }; 525 | 77B495BF192B063E00D8099C /* Build configuration list for PBXNativeTarget "CHAnimation" */ = { 526 | isa = XCConfigurationList; 527 | buildConfigurations = ( 528 | 77B495C0192B063E00D8099C /* Debug */, 529 | 77B495C1192B063E00D8099C /* Release */, 530 | ); 531 | defaultConfigurationIsVisible = 0; 532 | defaultConfigurationName = Release; 533 | }; 534 | 77B495C2192B063E00D8099C /* Build configuration list for PBXNativeTarget "CHAnimationTests" */ = { 535 | isa = XCConfigurationList; 536 | buildConfigurations = ( 537 | 77B495C3192B063E00D8099C /* Debug */, 538 | 77B495C4192B063E00D8099C /* Release */, 539 | ); 540 | defaultConfigurationIsVisible = 0; 541 | defaultConfigurationName = Release; 542 | }; 543 | /* End XCConfigurationList section */ 544 | }; 545 | rootObject = 77B49582192B063E00D8099C /* Project object */; 546 | } 547 | -------------------------------------------------------------------------------- /CHAnimation/CHAnimation-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | com.hangchen.${PRODUCT_NAME:rfc1034identifier} 13 | CFBundleInfoDictionaryVersion 14 | 6.0 15 | CFBundleName 16 | ${PRODUCT_NAME} 17 | CFBundlePackageType 18 | APPL 19 | CFBundleShortVersionString 20 | 1.0 21 | CFBundleSignature 22 | ???? 23 | CFBundleVersion 24 | 1.0 25 | LSRequiresIPhoneOS 26 | 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 | -------------------------------------------------------------------------------- /CHAnimation/CHAnimation-Prefix.pch: -------------------------------------------------------------------------------- 1 | // 2 | // Prefix header 3 | // 4 | // The contents of this file are implicitly included at the beginning of every source file. 5 | // 6 | 7 | #import 8 | 9 | #ifndef __IPHONE_5_0 10 | #warning "This project uses features only available in iOS SDK 5.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | #import 15 | #import 16 | #endif 17 | -------------------------------------------------------------------------------- /CHAnimation/CHAnimation/CHAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // CHAnimation.h 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | @class CHAnimationState; 28 | 29 | @interface CHAnimation : NSObject 30 | 31 | @property (nonatomic, assign)id obj; 32 | @property (assign, nonatomic) CFTimeInterval beginTime; 33 | @property (assign, nonatomic) CFTimeInterval duration; 34 | @property (copy, nonatomic) id fromValue; 35 | @property (copy, nonatomic) id toValue; 36 | @property (readwrite, nonatomic, copy) id (^readBlock)(id obj); 37 | @property (readwrite, nonatomic, copy) void (^writeBlock)(id obj, id value); 38 | 39 | 40 | @end 41 | 42 | CHAnimationState *CHAnimationGetState(CHAnimation *a); 43 | 44 | @interface NSObject (CHAnimation) 45 | 46 | 47 | - (void)ch_addAnimation:(CHAnimation *)anim forKey:(NSString *)key; 48 | 49 | 50 | - (void)ch_removeAllAnimations; 51 | 52 | 53 | - (void)ch_removeAnimationForKey:(NSString *)key; 54 | 55 | 56 | @end 57 | -------------------------------------------------------------------------------- /CHAnimation/CHAnimation/CHAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // CHAnimation.m 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import "CHAnimation.h" 27 | #import "CHAnimator.h" 28 | #import "CHAnimationState.h" 29 | 30 | 31 | 32 | @implementation CHAnimation 33 | { 34 | CHAnimationState *_state; 35 | 36 | } 37 | 38 | 39 | CHAnimationState *CHAnimationGetState(CHAnimation *a) 40 | { 41 | return a->_state; 42 | } 43 | 44 | - (id)init 45 | { 46 | self = [super init]; 47 | if (self) { 48 | _state = [[CHAnimationState alloc] initWithAnimation:self]; 49 | } 50 | return self; 51 | } 52 | 53 | 54 | @end 55 | 56 | @implementation NSObject (CHAnimation) 57 | 58 | - (void)ch_addAnimation:(CHAnimation *)anim forKey:(NSString *)key 59 | { 60 | anim.obj = self; 61 | [[CHAnimator sharedAnimator] addAnimation:anim forObject:self key:key]; 62 | } 63 | 64 | - (void)ch_removeAllAnimations 65 | { 66 | [[CHAnimator sharedAnimator] removeAllAnimationsForObject:self]; 67 | } 68 | 69 | - (void)ch_removeAnimationForKey:(NSString *)key 70 | { 71 | [[CHAnimator sharedAnimator] removeAnimationForObject:self key:key]; 72 | } 73 | 74 | 75 | 76 | @end 77 | 78 | -------------------------------------------------------------------------------- /CHAnimation/CHAnimation/CHAnimationState.h: -------------------------------------------------------------------------------- 1 | // 2 | // CHAnimationState.h 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | @class CHAnimation; 28 | @interface CHAnimationState : NSObject 29 | - (id)initWithAnimation:(CHAnimation*)animation; 30 | - (BOOL)startIfNeeded:(id)obj atTime:(CFTimeInterval)time; 31 | - (void)applyAnimation:(id)obj atTime:(CFTimeInterval)time; 32 | - (BOOL)isDone; 33 | - (CGFloat)progress; 34 | @end 35 | -------------------------------------------------------------------------------- /CHAnimation/CHAnimation/CHAnimationState.m: -------------------------------------------------------------------------------- 1 | // 2 | // CHAnimationState.m 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import "CHAnimationState.h" 27 | #import "CHAnimation.h" 28 | 29 | @implementation CHAnimationState 30 | { 31 | 32 | BOOL _active; 33 | __weak CHAnimation * _animation; 34 | CFTimeInterval _startTime; 35 | CFTimeInterval _currentTime; 36 | } 37 | 38 | - (id)initWithAnimation:(CHAnimation*)animation 39 | { 40 | self = [super init]; 41 | if (self) { 42 | _animation = animation; 43 | } 44 | return self; 45 | } 46 | 47 | 48 | - (BOOL)startIfNeeded:(id)obj atTime:(CFTimeInterval)time 49 | { 50 | if (!_active && time >= _animation.beginTime) { 51 | _active = YES; 52 | _startTime = time; 53 | } 54 | 55 | return _active; 56 | } 57 | 58 | - (void)applyAnimation:(id)obj atTime:(CFTimeInterval)time 59 | { 60 | _currentTime = time; 61 | 62 | CGFloat progress = self.progress; 63 | 64 | 65 | 66 | if (!strcmp([_animation.fromValue objCType], @encode(CGPoint)) && !strcmp([_animation.toValue objCType], @encode(CGPoint))) { 67 | CGPoint fromPoint = [_animation.fromValue CGPointValue]; 68 | CGPoint toPoint = [_animation.toValue CGPointValue]; 69 | CGPoint point = CGPointMake(fromPoint.x + (toPoint.x - fromPoint.x)*progress, fromPoint.y + (toPoint.y - fromPoint.y)*progress); 70 | _animation.writeBlock(_animation,[NSValue valueWithCGPoint:point]); 71 | } 72 | else if (!strcmp([_animation.fromValue objCType], @encode(CGSize)) && !strcmp([_animation.toValue objCType], @encode(CGSize))) { 73 | CGSize fromSize = [_animation.fromValue CGSizeValue]; 74 | CGSize toSize = [_animation.toValue CGSizeValue]; 75 | CGSize size = CGSizeMake(fromSize.width + (toSize.width - fromSize.width)*progress, fromSize.height + (toSize.height - fromSize.height)*progress); 76 | _animation.writeBlock(_animation,[NSValue valueWithCGSize:size]); 77 | } 78 | else if ([_animation.fromValue isKindOfClass:NSNumber.class] && [_animation.toValue isKindOfClass:NSNumber.class]) { 79 | CGFloat fromValue = [_animation.fromValue floatValue]; 80 | CGFloat toValue = [_animation.toValue floatValue]; 81 | CGFloat value = fromValue + (toValue - fromValue)*progress; 82 | _animation.writeBlock(_animation,[NSNumber numberWithFloat:value]); 83 | } 84 | 85 | } 86 | 87 | - (BOOL)isDone 88 | { 89 | if (_currentTime >= _startTime + _animation.duration) { 90 | return YES; 91 | } 92 | return NO; 93 | } 94 | 95 | - (CGFloat)progress 96 | { 97 | CGFloat _progress = (_currentTime - _startTime)/_animation.duration; 98 | if (_progress < 0) { 99 | _progress = 0; 100 | } 101 | if (_progress > 1) { 102 | _progress = 1.0; 103 | } 104 | return _progress; 105 | } 106 | 107 | 108 | @end 109 | -------------------------------------------------------------------------------- /CHAnimation/CHAnimation/CHAnimator.h: -------------------------------------------------------------------------------- 1 | // 2 | // CHAnimator.h 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | @class CHAnimation; 29 | @interface CHAnimator : NSObject 30 | 31 | + (instancetype)sharedAnimator; 32 | 33 | - (void)addAnimation:(CHAnimation *)anim forObject:(id)obj key:(NSString *)key; 34 | - (void)removeAllAnimationsForObject:(id)obj; 35 | - (void)removeAnimationForObject:(id)obj key:(NSString *)key; 36 | 37 | @end 38 | -------------------------------------------------------------------------------- /CHAnimation/CHAnimation/CHAnimator.m: -------------------------------------------------------------------------------- 1 | // 2 | // CHAnimator.m 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import "CHAnimator.h" 27 | #import "CHAnimation.h" 28 | #import "CHAnimationState.h" 29 | 30 | @interface CHAnimatorItem : NSObject 31 | @property(nonatomic, weak)id object; 32 | @property(nonatomic, copy)NSString *key; 33 | @property(nonatomic)CHAnimation *animation; 34 | @end 35 | 36 | @implementation CHAnimatorItem 37 | 38 | 39 | @end 40 | 41 | 42 | @interface CHAnimator () 43 | { 44 | CADisplayLink *_displayLink; 45 | NSMutableArray *_list; 46 | CFMutableDictionaryRef _dict; 47 | } 48 | @end 49 | 50 | 51 | 52 | @implementation CHAnimator 53 | 54 | 55 | 56 | static Boolean pointerEqual(const void *ptr1, const void *ptr2) { 57 | return ptr1 == ptr2; 58 | } 59 | 60 | static CFHashCode pointerHash(const void *ptr) { 61 | return (CFHashCode)(ptr); 62 | } 63 | 64 | 65 | + (id)sharedAnimator 66 | { 67 | static CHAnimator* _animator = nil; 68 | static dispatch_once_t onceToken; 69 | dispatch_once(&onceToken, ^{ 70 | _animator = [[CHAnimator alloc] init]; 71 | }); 72 | return _animator; 73 | } 74 | 75 | - (id)init 76 | { 77 | self = [super init]; 78 | if (self) { 79 | 80 | _displayLink = [CADisplayLink displayLinkWithTarget:self selector:@selector(render)]; 81 | _displayLink.paused = YES; 82 | [_displayLink addToRunLoop:[NSRunLoop mainRunLoop] forMode:NSRunLoopCommonModes]; 83 | 84 | 85 | CFDictionaryKeyCallBacks kcb = kCFTypeDictionaryKeyCallBacks; 86 | kcb.retain = NULL; 87 | kcb.release = NULL; 88 | kcb.equal = pointerEqual; 89 | kcb.hash = pointerHash; 90 | 91 | CFDictionaryValueCallBacks vcb = kCFTypeDictionaryValueCallBacks; 92 | 93 | _dict = CFDictionaryCreateMutable(NULL, 10, &kcb, &vcb); 94 | 95 | _list = [[NSMutableArray alloc] initWithCapacity:10]; 96 | 97 | } 98 | return self; 99 | } 100 | 101 | 102 | 103 | - (void)addAnimation:(CHAnimation *)anim forObject:(id)obj key:(NSString *)key 104 | { 105 | if (!anim || !obj) { 106 | return; 107 | } 108 | 109 | if (!key) { 110 | key = [[NSUUID UUID] UUIDString]; 111 | } 112 | 113 | NSMutableDictionary *animations = (__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj); 114 | 115 | if (nil == animations) { 116 | animations = [NSMutableDictionary dictionary]; 117 | CFDictionarySetValue(_dict, (__bridge void *)obj, (__bridge void *)animations); 118 | } else { 119 | CHAnimation *existingAnim = animations[key]; 120 | if (existingAnim) { 121 | if (existingAnim == anim) { 122 | return; 123 | } 124 | 125 | [self removeAnimationForObject:obj key:key]; 126 | } 127 | } 128 | animations[key] = anim; 129 | 130 | CHAnimatorItem *item = [CHAnimatorItem new]; 131 | item.key = key; 132 | item.object = obj; 133 | item.animation = anim; 134 | [_list addObject:item]; 135 | 136 | 137 | [self updateAnimating]; 138 | } 139 | 140 | - (void)removeAllAnimationsForObject:(id)obj 141 | { 142 | NSArray *animations = [(__bridge id)CFDictionaryGetValue(_dict, (__bridge void *)obj) allValues]; 143 | CFDictionaryRemoveValue(_dict, (__bridge void *)obj); 144 | 145 | if (0 == animations.count) 146 | return; 147 | 148 | for (CHAnimation* animation in animations) { 149 | 150 | for (NSInteger index = _list.count - 1; index >= 0; index--) { 151 | CHAnimatorItem *item = _list[index]; 152 | if ([animation isEqual:item.animation]) { 153 | [_list removeObject:item]; 154 | } 155 | } 156 | } 157 | [self updateAnimating]; 158 | 159 | } 160 | 161 | 162 | - (void)removeAnimationForObject:(id)obj key:(NSString *)key 163 | { 164 | NSMutableDictionary *animations = (__bridge id)CFDictionaryGetValue(self->_dict, (__bridge void *)obj); 165 | if (nil == animations) 166 | return; 167 | 168 | CHAnimation *anim = animations[key]; 169 | if (nil == anim) 170 | return; 171 | 172 | [animations removeObjectForKey:key]; 173 | 174 | 175 | for (NSInteger index = _list.count - 1; index >= 0; index--) { 176 | CHAnimatorItem *item = _list[index]; 177 | if ([anim isEqual:item.animation]) { 178 | [_list removeObject:item]; 179 | } 180 | } 181 | [self updateAnimating]; 182 | } 183 | 184 | - (void)updateAnimating 185 | { 186 | BOOL paused = (_list.count == 0); 187 | if (paused != _displayLink.paused) { 188 | _displayLink.paused = paused; 189 | } 190 | } 191 | 192 | - (void)render 193 | { 194 | CFTimeInterval time = CACurrentMediaTime(); 195 | 196 | [self renderTime:time]; 197 | } 198 | 199 | - (void)renderTime:(CFTimeInterval)time 200 | { 201 | [CATransaction begin]; 202 | [CATransaction setDisableActions:YES]; 203 | 204 | NSMutableArray *doneAnimations = [NSMutableArray new]; 205 | 206 | for (CHAnimatorItem *item in _list) { 207 | CHAnimationState *state = CHAnimationGetState(item.animation); 208 | 209 | if ([state startIfNeeded:item.animation atTime:time]) { 210 | [state applyAnimation:item.animation atTime:time]; 211 | 212 | if ([state isDone]) { 213 | 214 | [doneAnimations addObject:item]; 215 | } 216 | } 217 | 218 | } 219 | for (CHAnimatorItem *item in doneAnimations) { 220 | [self removeAnimationForObject:item.object key:item.key]; 221 | } 222 | 223 | 224 | 225 | [self updateAnimating]; 226 | 227 | [CATransaction commit]; 228 | } 229 | 230 | 231 | @end 232 | 233 | -------------------------------------------------------------------------------- /CHAnimation/CHAppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // CHAppDelegate.h 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | @interface CHAppDelegate : UIResponder 29 | 30 | @property (strong, nonatomic) UIWindow *window; 31 | 32 | @end 33 | -------------------------------------------------------------------------------- /CHAnimation/CHAppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // CHAppDelegate.m 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import "CHAppDelegate.h" 27 | #import "CHViewController.h" 28 | 29 | @implementation CHAppDelegate 30 | 31 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 32 | { 33 | // Override point for customization after application launch. 34 | self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; 35 | self.window.rootViewController = [CHViewController new]; 36 | [self.window makeKeyAndVisible]; 37 | return YES; 38 | } 39 | 40 | - (void)applicationWillResignActive:(UIApplication *)application 41 | { 42 | // 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. 43 | // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. 44 | } 45 | 46 | - (void)applicationDidEnterBackground:(UIApplication *)application 47 | { 48 | // 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. 49 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 50 | } 51 | 52 | - (void)applicationWillEnterForeground:(UIApplication *)application 53 | { 54 | // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. 55 | } 56 | 57 | - (void)applicationDidBecomeActive:(UIApplication *)application 58 | { 59 | // 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. 60 | } 61 | 62 | - (void)applicationWillTerminate:(UIApplication *)application 63 | { 64 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 65 | } 66 | 67 | @end 68 | -------------------------------------------------------------------------------- /CHAnimation/CHPopUpMenu.h: -------------------------------------------------------------------------------- 1 | // 2 | // CHPopUpMenu.h 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | @interface CHPopUpMenu : UIControl 29 | 30 | /* 31 | Direction: mid direction to where the submenu will point to 32 | iconArray: images array for the icons -- Works fine for 80x80px icons 33 | 34 | */ 35 | - (id) initWithFrame:(CGRect)frame 36 | direction:(CGFloat)directionInRadians 37 | iconArray:(NSArray *)icons; 38 | 39 | @end 40 | -------------------------------------------------------------------------------- /CHAnimation/CHPopUpMenu.m: -------------------------------------------------------------------------------- 1 | // 2 | // CHPopUpMenu.m 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import "CHPopUpMenu.h" 27 | #import "CHAnimation.h" 28 | 29 | #define CHPpopUpMenuItemSize 60 30 | 31 | @interface CHPopUpMenu () { 32 | BOOL _isMenuPresented; 33 | CGFloat _direction; 34 | NSMutableArray *_iconViews; 35 | UIImageView* _imageView; 36 | } 37 | @property (nonatomic, strong) NSArray *icons; 38 | 39 | @end 40 | 41 | @implementation CHPopUpMenu 42 | 43 | - (id)initWithFrame:(CGRect)frame 44 | { 45 | return [self initWithFrame:frame direction:0 iconArray:nil]; 46 | } 47 | 48 | - (id) initWithFrame:(CGRect)frame direction:(CGFloat)directionInRadians iconArray:(NSArray *)icons{ 49 | 50 | self = [super initWithFrame:frame]; 51 | if (self) { 52 | // Initialization code 53 | _isMenuPresented = NO; 54 | _direction = directionInRadians; 55 | self.icons = [[NSArray alloc]initWithArray:icons]; 56 | 57 | 58 | [self addSubview:({ 59 | _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"plus.png"]]; 60 | _imageView.frame = self.bounds; 61 | _imageView.autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth; 62 | _imageView; 63 | })]; 64 | 65 | [self addTarget:self action:@selector(controlPressed) forControlEvents:UIControlEventTouchUpInside]; 66 | } 67 | return self; 68 | } 69 | 70 | 71 | - (void) controlPressed { 72 | if (_isMenuPresented) { 73 | [self dismissSubMenu]; 74 | } 75 | else { 76 | [self presentSubMenu]; 77 | } 78 | } 79 | 80 | 81 | 82 | 83 | - (void) presentSubMenu { 84 | _isMenuPresented = YES; 85 | 86 | 87 | if (!_iconViews) { 88 | _iconViews = [[NSMutableArray alloc]init]; 89 | for (UIImage *iconImage in self.icons) { 90 | [self addSubview:({ 91 | UIImageView *iconView = [[UIImageView alloc]initWithImage:iconImage]; 92 | iconView.frame = CGRectMake(self.bounds.size.width/2 - CHPpopUpMenuItemSize/2, self.bounds.size.height/2 - CHPpopUpMenuItemSize/2, CHPpopUpMenuItemSize, CHPpopUpMenuItemSize); 93 | iconView.alpha = 0.0; 94 | [_iconViews addObject:iconView]; 95 | iconView; 96 | })]; 97 | } 98 | 99 | } 100 | 101 | 102 | int nIcons = [self.icons count]; 103 | int iconNumber = 0; 104 | 105 | CHAnimation *degree = [CHAnimation new]; 106 | degree.fromValue = @0; 107 | degree.toValue = @M_PI; 108 | degree.duration = 0.6; 109 | degree.writeBlock = ^(id obj, id value) { 110 | _imageView.layer.transform = CATransform3DMakeRotation([value floatValue], 0, 0, 1); 111 | }; 112 | [_imageView.layer ch_addAnimation:degree forKey:@"degree1"]; 113 | 114 | 115 | 116 | for (UIImageView *icon in _iconViews) { 117 | CHAnimation *alpha = [CHAnimation new]; 118 | alpha.fromValue = @0.0; 119 | alpha.toValue = @1.0; 120 | alpha.duration = 0.3; 121 | alpha.writeBlock = ^(id obj, id value) { 122 | icon.alpha = [value floatValue]; 123 | }; 124 | alpha.beginTime = CACurrentMediaTime() + iconNumber*0.1; 125 | [icon ch_addAnimation:alpha forKey:@"alpha1"]; 126 | 127 | 128 | CHAnimation *push = [CHAnimation new]; 129 | CGFloat angle = [self angleForIcon:iconNumber numberOfIcons:nIcons]; 130 | CGFloat radius = 90; 131 | push.beginTime = CACurrentMediaTime() + iconNumber*0.1; 132 | push.duration = 0.3; 133 | push.fromValue = [NSValue valueWithCGPoint:CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2)]; 134 | push.toValue = [NSValue valueWithCGPoint:CGPointMake(radius * cosf(angle) + self.bounds.size.width/2, radius * sinf(angle) + self.bounds.size.height/2)]; 135 | push.writeBlock = ^(id obj, id value) { 136 | icon.center = [value CGPointValue]; 137 | }; 138 | [icon ch_addAnimation:push forKey:@"push1"]; 139 | 140 | iconNumber += 1; 141 | } 142 | } 143 | 144 | 145 | - (void)dismissSubMenu { 146 | _isMenuPresented = NO; 147 | int iconNumber = 0; 148 | int nIcons = [self.icons count]; 149 | 150 | CHAnimation *degree = [CHAnimation new]; 151 | degree.fromValue = @M_PI; 152 | degree.toValue = @0; 153 | degree.duration = 0.6; 154 | degree.writeBlock = ^(id obj, id value) { 155 | _imageView.layer.transform = CATransform3DMakeRotation([value floatValue], 0, 0, 1); 156 | }; 157 | [_imageView.layer ch_addAnimation:degree forKey:@"degree1"]; 158 | 159 | 160 | for (UIImageView *icon in _iconViews) { 161 | CHAnimation *alpha = [CHAnimation new]; 162 | alpha.toValue = @0.0; 163 | alpha.fromValue = @1.0; 164 | alpha.duration = 0.3; 165 | alpha.writeBlock = ^(id obj, id value) { 166 | icon.alpha = [value floatValue]; 167 | }; 168 | alpha.beginTime = CACurrentMediaTime() + iconNumber*0.1; 169 | [icon ch_addAnimation:alpha forKey:@"alpha2"]; 170 | 171 | CHAnimation *push = [CHAnimation new]; 172 | CGFloat angle = [self angleForIcon:iconNumber numberOfIcons:nIcons]; 173 | CGFloat radius = 90; 174 | push.beginTime = CACurrentMediaTime() + iconNumber*0.1; 175 | push.duration = 0.3; 176 | 177 | push.toValue = [NSValue valueWithCGPoint:CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2)]; 178 | push.fromValue = [NSValue valueWithCGPoint:CGPointMake(radius * cosf(angle) + self.bounds.size.width/2, radius * sinf(angle) + self.bounds.size.height/2)]; 179 | push.writeBlock = ^(id obj, id value) { 180 | icon.center = [value CGPointValue]; 181 | }; 182 | [icon ch_addAnimation:push forKey:@"push2"]; 183 | 184 | iconNumber += 1; 185 | } 186 | 187 | 188 | 189 | } 190 | 191 | - (CGFloat) angleForIcon:(int)iconNumber numberOfIcons:(int)nIcons { 192 | CGFloat interSpace = M_PI_4; 193 | CGFloat totalAngle = (nIcons -1) * interSpace; 194 | CGFloat startAngle = _direction - totalAngle/2; 195 | 196 | return startAngle + iconNumber*interSpace; 197 | } 198 | 199 | @end 200 | -------------------------------------------------------------------------------- /CHAnimation/CHViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // CHViewController.h 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | @interface CHViewController : UIViewController 29 | 30 | @end 31 | -------------------------------------------------------------------------------- /CHAnimation/CHViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // CHViewController.m 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import "CHViewController.h" 27 | #import "CHPopUpMenu.h" 28 | 29 | @interface CHViewController () 30 | 31 | @end 32 | 33 | @implementation CHViewController 34 | 35 | - (void)viewDidLoad 36 | { 37 | [super viewDidLoad]; 38 | // Do any additional setup after loading the view, typically from a nib. 39 | self.view.backgroundColor = [UIColor whiteColor]; 40 | 41 | [self.view addSubview:({ 42 | UIImageView* imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.png"]]; 43 | imageView.frame = self.view.bounds; 44 | imageView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; 45 | imageView; 46 | })]; 47 | 48 | [self.view addSubview:({ 49 | UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(10, 20, 300, 200)]; 50 | NSString *text = @"CHAnimation is a project used to demonstrate how to write your own animation engine, inspired by Facebook Pop, with only 600 lines of Objective-C you can understand.\n\nYou can also use this project to help learning Facebook Pop."; 51 | label.text = text; 52 | label.numberOfLines = 0; 53 | label.font = [UIFont systemFontOfSize:17]; 54 | label.textColor = [UIColor colorWithRed:94/255.0f green:38/255.0f blue:5/255.0f alpha:1.0]; 55 | label.backgroundColor = [UIColor clearColor]; 56 | 57 | NSMutableAttributedString *attributedText = 58 | [[NSMutableAttributedString alloc] initWithAttributedString:label.attributedText]; 59 | 60 | [attributedText setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:28/255.0f green:160/255.0f blue:170/255.0f alpha:1.0]} range:[text rangeOfString:@"CHAnimation"]]; 61 | 62 | [attributedText setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:28/255.0f green:160/255.0f blue:170/255.0f alpha:1.0]} range:[text rangeOfString:@"Facebook Pop"]]; 63 | [attributedText setAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithRed:28/255.0f green:160/255.0f blue:170/255.0f alpha:1.0]} range:[text rangeOfString:@"Facebook Pop" options:NSBackwardsSearch]]; 64 | 65 | 66 | label.attributedText = attributedText; 67 | 68 | label; 69 | })]; 70 | 71 | 72 | 73 | 74 | 75 | [self.view addSubview:({ 76 | NSArray *icons = @[[UIImage imageNamed:@"facebook.png"],[UIImage imageNamed:@"twitter.png"],[UIImage imageNamed:@"googleplus.png"],[UIImage imageNamed:@"pinterest.png"],[UIImage imageNamed:@"linkedin.png"],[UIImage imageNamed:@"youtube.png"],[UIImage imageNamed:@"tumblr.png"],[UIImage imageNamed:@"skype.png"]]; 77 | 78 | CHPopUpMenu *popUp = [[CHPopUpMenu alloc]initWithFrame:CGRectMake(145, 420, 30, 30) 79 | direction:-M_PI/2 80 | iconArray:icons]; 81 | popUp; 82 | })]; 83 | 84 | 85 | 86 | 87 | 88 | } 89 | 90 | 91 | 92 | - (void)didReceiveMemoryWarning 93 | { 94 | [super didReceiveMemoryWarning]; 95 | // Dispose of any resources that can be recreated. 96 | } 97 | 98 | @end 99 | -------------------------------------------------------------------------------- /CHAnimation/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "40x40", 11 | "scale" : "2x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "60x60", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "ipad", 20 | "size" : "29x29", 21 | "scale" : "1x" 22 | }, 23 | { 24 | "idiom" : "ipad", 25 | "size" : "29x29", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "ipad", 30 | "size" : "40x40", 31 | "scale" : "1x" 32 | }, 33 | { 34 | "idiom" : "ipad", 35 | "size" : "40x40", 36 | "scale" : "2x" 37 | }, 38 | { 39 | "idiom" : "ipad", 40 | "size" : "76x76", 41 | "scale" : "1x" 42 | }, 43 | { 44 | "idiom" : "ipad", 45 | "size" : "76x76", 46 | "scale" : "2x" 47 | } 48 | ], 49 | "info" : { 50 | "version" : 1, 51 | "author" : "xcode" 52 | } 53 | } -------------------------------------------------------------------------------- /CHAnimation/Images.xcassets/LaunchImage.launchimage/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "orientation" : "portrait", 5 | "idiom" : "iphone", 6 | "extent" : "full-screen", 7 | "minimum-system-version" : "7.0", 8 | "scale" : "2x" 9 | }, 10 | { 11 | "orientation" : "portrait", 12 | "idiom" : "iphone", 13 | "subtype" : "retina4", 14 | "extent" : "full-screen", 15 | "minimum-system-version" : "7.0", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "orientation" : "portrait", 20 | "idiom" : "ipad", 21 | "extent" : "full-screen", 22 | "minimum-system-version" : "7.0", 23 | "scale" : "1x" 24 | }, 25 | { 26 | "orientation" : "landscape", 27 | "idiom" : "ipad", 28 | "extent" : "full-screen", 29 | "minimum-system-version" : "7.0", 30 | "scale" : "1x" 31 | }, 32 | { 33 | "orientation" : "portrait", 34 | "idiom" : "ipad", 35 | "extent" : "full-screen", 36 | "minimum-system-version" : "7.0", 37 | "scale" : "2x" 38 | }, 39 | { 40 | "orientation" : "landscape", 41 | "idiom" : "ipad", 42 | "extent" : "full-screen", 43 | "minimum-system-version" : "7.0", 44 | "scale" : "2x" 45 | } 46 | ], 47 | "info" : { 48 | "version" : 1, 49 | "author" : "xcode" 50 | } 51 | } -------------------------------------------------------------------------------- /CHAnimation/Resources/background@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/background@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/facebook@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/facebook@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/googleplus@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/googleplus@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/linkedin@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/linkedin@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/pinterest@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/pinterest@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/plus@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/plus@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/skype@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/skype@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/tumblr@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/tumblr@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/twitter@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/twitter@2x.png -------------------------------------------------------------------------------- /CHAnimation/Resources/youtube@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cyndibaby905/CHAnimation/8c6ba3f9626e16ebe8e98d286d0c40e3cfaf1e52/CHAnimation/Resources/youtube@2x.png -------------------------------------------------------------------------------- /CHAnimation/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /CHAnimation/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // CHAnimation 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | #import "CHAppDelegate.h" 29 | 30 | int main(int argc, char * argv[]) 31 | { 32 | @autoreleasepool { 33 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([CHAppDelegate class])); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /CHAnimationTests/CHAnimationTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | com.hangchen.${PRODUCT_NAME:rfc1034identifier} 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundlePackageType 14 | BNDL 15 | CFBundleShortVersionString 16 | 1.0 17 | CFBundleSignature 18 | ???? 19 | CFBundleVersion 20 | 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /CHAnimationTests/CHAnimationTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // CHAnimationTests.m 3 | // CHAnimationTests 4 | // 5 | // Created by hangchen on 5/20/14. 6 | // Copyright (c) 2014 Hang Chen (https://github.com/cyndibaby905) 7 | // 8 | // Permission is hereby granted, free of charge, to any person obtaining a copy 9 | // of this software and associated documentation files (the "Software"), to deal 10 | // in the Software without restriction, including without limitation the rights 11 | // to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 12 | // copies of the Software, and to permit persons to whom the Software is 13 | // furnished to do so, subject to the following conditions: 14 | // 15 | // The above copyright notice and this permission notice shall be included in 16 | // all copies or substantial portions of the Software. 17 | // 18 | // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | // AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | // OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 24 | // THE SOFTWARE. 25 | 26 | #import 27 | 28 | @interface CHAnimationTests : XCTestCase 29 | 30 | @end 31 | 32 | @implementation CHAnimationTests 33 | 34 | - (void)setUp 35 | { 36 | [super setUp]; 37 | // Put setup code here. This method is called before the invocation of each test method in the class. 38 | } 39 | 40 | - (void)tearDown 41 | { 42 | // Put teardown code here. This method is called after the invocation of each test method in the class. 43 | [super tearDown]; 44 | } 45 | 46 | - (void)testExample 47 | { 48 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 49 | } 50 | 51 | @end 52 | -------------------------------------------------------------------------------- /CHAnimationTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Hang Chen 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. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## CHAnimation ## 2 | 3 | `CHAnimation` is a project used to demonstrate how to write your own animation engine, inspired by [Facebook Pop](https://github.com/facebook/pop), with only 600 lines of Objective-C you can understand. 4 | 5 | You can also use this project to help learning [Facebook Pop](https://github.com/facebook/pop). 6 | 7 | 8 | 9 | ## Requirements ## 10 | 11 | `CHAnimation` requires Xcode 5, targeting either iOS 5.0 and above, ARC-enabled. 12 | 13 | 14 | 15 | ## Types ## 16 | 17 | Unlike [Facebook Pop](https://github.com/facebook/pop), `CHAnimation` supports only one animation type, that is linear animation. The main purpose of this project is to help developer understand how an animation engine works, so I tried my best to keep the code small and clean. I think if you finished reading the code of `CHAnimation`, you can add more `timingFunction` as you want. 18 | 19 | Currently, `CHAnimation` supports `CGSize`, `CGPoint` and `NSNumber` as animated values, you can add more types if you want. 20 | 21 | 22 | 23 | ## How to use ## 24 | 25 | `CHAnimation` adopts the Core Animation explicit animation programming model, the interfaces are almost the same: 26 | 27 | 28 | #import "CHAnimation.h" 29 | 30 | CHAnimation *animation = [CHAnimation new]; 31 | animation.duration = 0.4; 32 | 33 | animation.writeBlock = ^(id obj, id value) { 34 | button.center = [value CGPointValue]; 35 | }; 36 | 37 | animation.fromValue = [NSValue valueWithCGPoint:CGPointMake(70, 70)]; 38 | animation.toValue = [NSValue valueWithCGPoint:CGPointMake(170, 170)]; 39 | 40 | [button ch_addAnimation:animation forKey:@"animation"]; 41 | 42 | 43 | 44 | 45 | ## Resources ## 46 | 47 | A collection of links to external resources may help you to understand the code: 48 | 49 | * [Apple – Core Animation Programming Guide](https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CoreAnimation_guide/Introduction/Introduction.html) 50 | * [AGGeometryKit+POP - Animating Quadrilaterals with Pop](https://github.com/hfossli/aggeometrykit-pop) 51 | * [Facebook Pop – Extensible iOS and OS X animation library](https://github.com/facebook/pop) 52 | * [Building Paper – Full Length Event](https://www.youtube.com/watch?v=OiY1cheLpmI) 53 | 54 | 55 | 56 | 57 | ## How it looks ## 58 | ![CHAnimation] (https://raw.github.com/cyndibaby905/CHAnimation/master/CHAnimation.gif) 59 | 60 | 61 | ## Lincense ## 62 | 63 | `CHAnimation` is available under the MIT license. See the LICENSE file for more info. 64 | 65 | --------------------------------------------------------------------------------