├── .gitignore ├── AnimatedBubbleTest ├── AnimatedBubbleTest.xcodeproj │ ├── project.pbxproj │ └── project.xcworkspace │ │ └── contents.xcworkspacedata ├── AnimatedBubbleTest │ ├── AppDelegate.h │ ├── AppDelegate.m │ ├── Base.lproj │ │ ├── LaunchScreen.xib │ │ └── Main.storyboard │ ├── BubbleView │ │ ├── BubbleLayer.h │ │ ├── BubbleLayer.m │ │ ├── BubbleView.h │ │ └── BubbleView.m │ ├── Images.xcassets │ │ └── AppIcon.appiconset │ │ │ └── Contents.json │ ├── Info.plist │ ├── KYSpringLayerAnimation.h │ ├── KYSpringLayerAnimation.m │ ├── SCCircleMath.h │ ├── SCCircleMath.m │ ├── ViewController.h │ ├── ViewController.m │ └── main.m └── AnimatedBubbleTestTests │ ├── AnimatedBubbleTestTests.m │ └── Info.plist ├── LICENSE ├── README.md └── ScreenShot.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | # 3 | build/ 4 | *.pbxuser 5 | !default.pbxuser 6 | *.mode1v3 7 | !default.mode1v3 8 | *.mode2v3 9 | !default.mode2v3 10 | *.perspectivev3 11 | !default.perspectivev3 12 | xcuserdata 13 | *.xccheckout 14 | *.moved-aside 15 | DerivedData 16 | *.hmap 17 | *.ipa 18 | *.xcuserstate 19 | 20 | # CocoaPods 21 | # 22 | # We recommend against adding the Pods directory to your .gitignore. However 23 | # you should judge for yourself, the pros and cons are mentioned at: 24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control 25 | # 26 | #Pods/ 27 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 636B05121B894476009FF248 /* KYSpringLayerAnimation.m in Sources */ = {isa = PBXBuildFile; fileRef = 636B05111B894476009FF248 /* KYSpringLayerAnimation.m */; }; 11 | 636B05151B894C35009FF248 /* SCCircleMath.m in Sources */ = {isa = PBXBuildFile; fileRef = 636B05141B894C35009FF248 /* SCCircleMath.m */; }; 12 | 636B05191B89A9AB009FF248 /* BubbleLayer.m in Sources */ = {isa = PBXBuildFile; fileRef = 636B05181B89A9AB009FF248 /* BubbleLayer.m */; }; 13 | 636B051C1B89AA4D009FF248 /* BubbleView.m in Sources */ = {isa = PBXBuildFile; fileRef = 636B051B1B89AA4D009FF248 /* BubbleView.m */; }; 14 | 63A27EF11B88342800F8197E /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A27EF01B88342800F8197E /* main.m */; }; 15 | 63A27EF41B88342800F8197E /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A27EF31B88342800F8197E /* AppDelegate.m */; }; 16 | 63A27EF71B88342800F8197E /* ViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A27EF61B88342800F8197E /* ViewController.m */; }; 17 | 63A27EFA1B88342800F8197E /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 63A27EF81B88342800F8197E /* Main.storyboard */; }; 18 | 63A27EFC1B88342800F8197E /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 63A27EFB1B88342800F8197E /* Images.xcassets */; }; 19 | 63A27EFF1B88342800F8197E /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 63A27EFD1B88342800F8197E /* LaunchScreen.xib */; }; 20 | 63A27F0B1B88342800F8197E /* AnimatedBubbleTestTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 63A27F0A1B88342800F8197E /* AnimatedBubbleTestTests.m */; }; 21 | /* End PBXBuildFile section */ 22 | 23 | /* Begin PBXContainerItemProxy section */ 24 | 63A27F051B88342800F8197E /* PBXContainerItemProxy */ = { 25 | isa = PBXContainerItemProxy; 26 | containerPortal = 63A27EE31B88342800F8197E /* Project object */; 27 | proxyType = 1; 28 | remoteGlobalIDString = 63A27EEA1B88342800F8197E; 29 | remoteInfo = AnimatedBubbleTest; 30 | }; 31 | /* End PBXContainerItemProxy section */ 32 | 33 | /* Begin PBXFileReference section */ 34 | 636B05101B894476009FF248 /* KYSpringLayerAnimation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KYSpringLayerAnimation.h; sourceTree = ""; }; 35 | 636B05111B894476009FF248 /* KYSpringLayerAnimation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = KYSpringLayerAnimation.m; sourceTree = ""; }; 36 | 636B05131B894C35009FF248 /* SCCircleMath.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SCCircleMath.h; sourceTree = ""; }; 37 | 636B05141B894C35009FF248 /* SCCircleMath.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SCCircleMath.m; sourceTree = ""; }; 38 | 636B05171B89A9AB009FF248 /* BubbleLayer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BubbleLayer.h; sourceTree = ""; }; 39 | 636B05181B89A9AB009FF248 /* BubbleLayer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BubbleLayer.m; sourceTree = ""; }; 40 | 636B051A1B89AA4D009FF248 /* BubbleView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BubbleView.h; sourceTree = ""; }; 41 | 636B051B1B89AA4D009FF248 /* BubbleView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BubbleView.m; sourceTree = ""; }; 42 | 63A27EEB1B88342800F8197E /* AnimatedBubbleTest.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AnimatedBubbleTest.app; sourceTree = BUILT_PRODUCTS_DIR; }; 43 | 63A27EEF1B88342800F8197E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 44 | 63A27EF01B88342800F8197E /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 45 | 63A27EF21B88342800F8197E /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 46 | 63A27EF31B88342800F8197E /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 47 | 63A27EF51B88342800F8197E /* ViewController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; 48 | 63A27EF61B88342800F8197E /* ViewController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ViewController.m; sourceTree = ""; }; 49 | 63A27EF91B88342800F8197E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; }; 50 | 63A27EFB1B88342800F8197E /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 51 | 63A27EFE1B88342800F8197E /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; 52 | 63A27F041B88342800F8197E /* AnimatedBubbleTestTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = AnimatedBubbleTestTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 53 | 63A27F091B88342800F8197E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; 54 | 63A27F0A1B88342800F8197E /* AnimatedBubbleTestTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AnimatedBubbleTestTests.m; sourceTree = ""; }; 55 | /* End PBXFileReference section */ 56 | 57 | /* Begin PBXFrameworksBuildPhase section */ 58 | 63A27EE81B88342800F8197E /* Frameworks */ = { 59 | isa = PBXFrameworksBuildPhase; 60 | buildActionMask = 2147483647; 61 | files = ( 62 | ); 63 | runOnlyForDeploymentPostprocessing = 0; 64 | }; 65 | 63A27F011B88342800F8197E /* Frameworks */ = { 66 | isa = PBXFrameworksBuildPhase; 67 | buildActionMask = 2147483647; 68 | files = ( 69 | ); 70 | runOnlyForDeploymentPostprocessing = 0; 71 | }; 72 | /* End PBXFrameworksBuildPhase section */ 73 | 74 | /* Begin PBXGroup section */ 75 | 636B05161B89A9AB009FF248 /* BubbleView */ = { 76 | isa = PBXGroup; 77 | children = ( 78 | 636B051A1B89AA4D009FF248 /* BubbleView.h */, 79 | 636B051B1B89AA4D009FF248 /* BubbleView.m */, 80 | 636B05171B89A9AB009FF248 /* BubbleLayer.h */, 81 | 636B05181B89A9AB009FF248 /* BubbleLayer.m */, 82 | ); 83 | path = BubbleView; 84 | sourceTree = ""; 85 | }; 86 | 636B051D1B89B051009FF248 /* Utils */ = { 87 | isa = PBXGroup; 88 | children = ( 89 | 636B05131B894C35009FF248 /* SCCircleMath.h */, 90 | 636B05141B894C35009FF248 /* SCCircleMath.m */, 91 | 636B05101B894476009FF248 /* KYSpringLayerAnimation.h */, 92 | 636B05111B894476009FF248 /* KYSpringLayerAnimation.m */, 93 | ); 94 | name = Utils; 95 | sourceTree = ""; 96 | }; 97 | 63A27EE21B88342800F8197E = { 98 | isa = PBXGroup; 99 | children = ( 100 | 63A27EED1B88342800F8197E /* AnimatedBubbleTest */, 101 | 63A27F071B88342800F8197E /* AnimatedBubbleTestTests */, 102 | 63A27EEC1B88342800F8197E /* Products */, 103 | ); 104 | sourceTree = ""; 105 | }; 106 | 63A27EEC1B88342800F8197E /* Products */ = { 107 | isa = PBXGroup; 108 | children = ( 109 | 63A27EEB1B88342800F8197E /* AnimatedBubbleTest.app */, 110 | 63A27F041B88342800F8197E /* AnimatedBubbleTestTests.xctest */, 111 | ); 112 | name = Products; 113 | sourceTree = ""; 114 | }; 115 | 63A27EED1B88342800F8197E /* AnimatedBubbleTest */ = { 116 | isa = PBXGroup; 117 | children = ( 118 | 63A27EF21B88342800F8197E /* AppDelegate.h */, 119 | 63A27EF31B88342800F8197E /* AppDelegate.m */, 120 | 63A27EF51B88342800F8197E /* ViewController.h */, 121 | 63A27EF61B88342800F8197E /* ViewController.m */, 122 | 636B05161B89A9AB009FF248 /* BubbleView */, 123 | 636B051D1B89B051009FF248 /* Utils */, 124 | 63A27EF81B88342800F8197E /* Main.storyboard */, 125 | 63A27EFB1B88342800F8197E /* Images.xcassets */, 126 | 63A27EFD1B88342800F8197E /* LaunchScreen.xib */, 127 | 63A27EEE1B88342800F8197E /* Supporting Files */, 128 | ); 129 | path = AnimatedBubbleTest; 130 | sourceTree = ""; 131 | }; 132 | 63A27EEE1B88342800F8197E /* Supporting Files */ = { 133 | isa = PBXGroup; 134 | children = ( 135 | 63A27EEF1B88342800F8197E /* Info.plist */, 136 | 63A27EF01B88342800F8197E /* main.m */, 137 | ); 138 | name = "Supporting Files"; 139 | sourceTree = ""; 140 | }; 141 | 63A27F071B88342800F8197E /* AnimatedBubbleTestTests */ = { 142 | isa = PBXGroup; 143 | children = ( 144 | 63A27F0A1B88342800F8197E /* AnimatedBubbleTestTests.m */, 145 | 63A27F081B88342800F8197E /* Supporting Files */, 146 | ); 147 | path = AnimatedBubbleTestTests; 148 | sourceTree = ""; 149 | }; 150 | 63A27F081B88342800F8197E /* Supporting Files */ = { 151 | isa = PBXGroup; 152 | children = ( 153 | 63A27F091B88342800F8197E /* Info.plist */, 154 | ); 155 | name = "Supporting Files"; 156 | sourceTree = ""; 157 | }; 158 | /* End PBXGroup section */ 159 | 160 | /* Begin PBXNativeTarget section */ 161 | 63A27EEA1B88342800F8197E /* AnimatedBubbleTest */ = { 162 | isa = PBXNativeTarget; 163 | buildConfigurationList = 63A27F0E1B88342800F8197E /* Build configuration list for PBXNativeTarget "AnimatedBubbleTest" */; 164 | buildPhases = ( 165 | 63A27EE71B88342800F8197E /* Sources */, 166 | 63A27EE81B88342800F8197E /* Frameworks */, 167 | 63A27EE91B88342800F8197E /* Resources */, 168 | ); 169 | buildRules = ( 170 | ); 171 | dependencies = ( 172 | ); 173 | name = AnimatedBubbleTest; 174 | productName = AnimatedBubbleTest; 175 | productReference = 63A27EEB1B88342800F8197E /* AnimatedBubbleTest.app */; 176 | productType = "com.apple.product-type.application"; 177 | }; 178 | 63A27F031B88342800F8197E /* AnimatedBubbleTestTests */ = { 179 | isa = PBXNativeTarget; 180 | buildConfigurationList = 63A27F111B88342800F8197E /* Build configuration list for PBXNativeTarget "AnimatedBubbleTestTests" */; 181 | buildPhases = ( 182 | 63A27F001B88342800F8197E /* Sources */, 183 | 63A27F011B88342800F8197E /* Frameworks */, 184 | 63A27F021B88342800F8197E /* Resources */, 185 | ); 186 | buildRules = ( 187 | ); 188 | dependencies = ( 189 | 63A27F061B88342800F8197E /* PBXTargetDependency */, 190 | ); 191 | name = AnimatedBubbleTestTests; 192 | productName = AnimatedBubbleTestTests; 193 | productReference = 63A27F041B88342800F8197E /* AnimatedBubbleTestTests.xctest */; 194 | productType = "com.apple.product-type.bundle.unit-test"; 195 | }; 196 | /* End PBXNativeTarget section */ 197 | 198 | /* Begin PBXProject section */ 199 | 63A27EE31B88342800F8197E /* Project object */ = { 200 | isa = PBXProject; 201 | attributes = { 202 | LastUpgradeCheck = 0630; 203 | ORGANIZATIONNAME = sgcy; 204 | TargetAttributes = { 205 | 63A27EEA1B88342800F8197E = { 206 | CreatedOnToolsVersion = 6.3.1; 207 | }; 208 | 63A27F031B88342800F8197E = { 209 | CreatedOnToolsVersion = 6.3.1; 210 | TestTargetID = 63A27EEA1B88342800F8197E; 211 | }; 212 | }; 213 | }; 214 | buildConfigurationList = 63A27EE61B88342800F8197E /* Build configuration list for PBXProject "AnimatedBubbleTest" */; 215 | compatibilityVersion = "Xcode 3.2"; 216 | developmentRegion = English; 217 | hasScannedForEncodings = 0; 218 | knownRegions = ( 219 | en, 220 | Base, 221 | ); 222 | mainGroup = 63A27EE21B88342800F8197E; 223 | productRefGroup = 63A27EEC1B88342800F8197E /* Products */; 224 | projectDirPath = ""; 225 | projectRoot = ""; 226 | targets = ( 227 | 63A27EEA1B88342800F8197E /* AnimatedBubbleTest */, 228 | 63A27F031B88342800F8197E /* AnimatedBubbleTestTests */, 229 | ); 230 | }; 231 | /* End PBXProject section */ 232 | 233 | /* Begin PBXResourcesBuildPhase section */ 234 | 63A27EE91B88342800F8197E /* Resources */ = { 235 | isa = PBXResourcesBuildPhase; 236 | buildActionMask = 2147483647; 237 | files = ( 238 | 63A27EFA1B88342800F8197E /* Main.storyboard in Resources */, 239 | 63A27EFF1B88342800F8197E /* LaunchScreen.xib in Resources */, 240 | 63A27EFC1B88342800F8197E /* Images.xcassets in Resources */, 241 | ); 242 | runOnlyForDeploymentPostprocessing = 0; 243 | }; 244 | 63A27F021B88342800F8197E /* Resources */ = { 245 | isa = PBXResourcesBuildPhase; 246 | buildActionMask = 2147483647; 247 | files = ( 248 | ); 249 | runOnlyForDeploymentPostprocessing = 0; 250 | }; 251 | /* End PBXResourcesBuildPhase section */ 252 | 253 | /* Begin PBXSourcesBuildPhase section */ 254 | 63A27EE71B88342800F8197E /* Sources */ = { 255 | isa = PBXSourcesBuildPhase; 256 | buildActionMask = 2147483647; 257 | files = ( 258 | 636B05191B89A9AB009FF248 /* BubbleLayer.m in Sources */, 259 | 636B051C1B89AA4D009FF248 /* BubbleView.m in Sources */, 260 | 63A27EF71B88342800F8197E /* ViewController.m in Sources */, 261 | 63A27EF41B88342800F8197E /* AppDelegate.m in Sources */, 262 | 636B05151B894C35009FF248 /* SCCircleMath.m in Sources */, 263 | 636B05121B894476009FF248 /* KYSpringLayerAnimation.m in Sources */, 264 | 63A27EF11B88342800F8197E /* main.m in Sources */, 265 | ); 266 | runOnlyForDeploymentPostprocessing = 0; 267 | }; 268 | 63A27F001B88342800F8197E /* Sources */ = { 269 | isa = PBXSourcesBuildPhase; 270 | buildActionMask = 2147483647; 271 | files = ( 272 | 63A27F0B1B88342800F8197E /* AnimatedBubbleTestTests.m in Sources */, 273 | ); 274 | runOnlyForDeploymentPostprocessing = 0; 275 | }; 276 | /* End PBXSourcesBuildPhase section */ 277 | 278 | /* Begin PBXTargetDependency section */ 279 | 63A27F061B88342800F8197E /* PBXTargetDependency */ = { 280 | isa = PBXTargetDependency; 281 | target = 63A27EEA1B88342800F8197E /* AnimatedBubbleTest */; 282 | targetProxy = 63A27F051B88342800F8197E /* PBXContainerItemProxy */; 283 | }; 284 | /* End PBXTargetDependency section */ 285 | 286 | /* Begin PBXVariantGroup section */ 287 | 63A27EF81B88342800F8197E /* Main.storyboard */ = { 288 | isa = PBXVariantGroup; 289 | children = ( 290 | 63A27EF91B88342800F8197E /* Base */, 291 | ); 292 | name = Main.storyboard; 293 | sourceTree = ""; 294 | }; 295 | 63A27EFD1B88342800F8197E /* LaunchScreen.xib */ = { 296 | isa = PBXVariantGroup; 297 | children = ( 298 | 63A27EFE1B88342800F8197E /* Base */, 299 | ); 300 | name = LaunchScreen.xib; 301 | sourceTree = ""; 302 | }; 303 | /* End PBXVariantGroup section */ 304 | 305 | /* Begin XCBuildConfiguration section */ 306 | 63A27F0C1B88342800F8197E /* Debug */ = { 307 | isa = XCBuildConfiguration; 308 | buildSettings = { 309 | ALWAYS_SEARCH_USER_PATHS = NO; 310 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 311 | CLANG_CXX_LIBRARY = "libc++"; 312 | CLANG_ENABLE_MODULES = YES; 313 | CLANG_ENABLE_OBJC_ARC = YES; 314 | CLANG_WARN_BOOL_CONVERSION = YES; 315 | CLANG_WARN_CONSTANT_CONVERSION = YES; 316 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 317 | CLANG_WARN_EMPTY_BODY = YES; 318 | CLANG_WARN_ENUM_CONVERSION = YES; 319 | CLANG_WARN_INT_CONVERSION = YES; 320 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 321 | CLANG_WARN_UNREACHABLE_CODE = YES; 322 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 323 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 324 | COPY_PHASE_STRIP = NO; 325 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 326 | ENABLE_STRICT_OBJC_MSGSEND = YES; 327 | GCC_C_LANGUAGE_STANDARD = gnu99; 328 | GCC_DYNAMIC_NO_PIC = NO; 329 | GCC_NO_COMMON_BLOCKS = YES; 330 | GCC_OPTIMIZATION_LEVEL = 0; 331 | GCC_PREPROCESSOR_DEFINITIONS = ( 332 | "DEBUG=1", 333 | "$(inherited)", 334 | ); 335 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 336 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 337 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 338 | GCC_WARN_UNDECLARED_SELECTOR = YES; 339 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 340 | GCC_WARN_UNUSED_FUNCTION = YES; 341 | GCC_WARN_UNUSED_VARIABLE = YES; 342 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 343 | MTL_ENABLE_DEBUG_INFO = YES; 344 | ONLY_ACTIVE_ARCH = YES; 345 | SDKROOT = iphoneos; 346 | }; 347 | name = Debug; 348 | }; 349 | 63A27F0D1B88342800F8197E /* Release */ = { 350 | isa = XCBuildConfiguration; 351 | buildSettings = { 352 | ALWAYS_SEARCH_USER_PATHS = NO; 353 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 354 | CLANG_CXX_LIBRARY = "libc++"; 355 | CLANG_ENABLE_MODULES = YES; 356 | CLANG_ENABLE_OBJC_ARC = YES; 357 | CLANG_WARN_BOOL_CONVERSION = YES; 358 | CLANG_WARN_CONSTANT_CONVERSION = YES; 359 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 360 | CLANG_WARN_EMPTY_BODY = YES; 361 | CLANG_WARN_ENUM_CONVERSION = YES; 362 | CLANG_WARN_INT_CONVERSION = YES; 363 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 364 | CLANG_WARN_UNREACHABLE_CODE = YES; 365 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 366 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 367 | COPY_PHASE_STRIP = NO; 368 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; 369 | ENABLE_NS_ASSERTIONS = NO; 370 | ENABLE_STRICT_OBJC_MSGSEND = YES; 371 | GCC_C_LANGUAGE_STANDARD = gnu99; 372 | GCC_NO_COMMON_BLOCKS = YES; 373 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 374 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 375 | GCC_WARN_UNDECLARED_SELECTOR = YES; 376 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; 377 | GCC_WARN_UNUSED_FUNCTION = YES; 378 | GCC_WARN_UNUSED_VARIABLE = YES; 379 | IPHONEOS_DEPLOYMENT_TARGET = 8.3; 380 | MTL_ENABLE_DEBUG_INFO = NO; 381 | SDKROOT = iphoneos; 382 | VALIDATE_PRODUCT = YES; 383 | }; 384 | name = Release; 385 | }; 386 | 63A27F0F1B88342800F8197E /* Debug */ = { 387 | isa = XCBuildConfiguration; 388 | buildSettings = { 389 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 390 | INFOPLIST_FILE = AnimatedBubbleTest/Info.plist; 391 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 392 | PRODUCT_NAME = "$(TARGET_NAME)"; 393 | }; 394 | name = Debug; 395 | }; 396 | 63A27F101B88342800F8197E /* Release */ = { 397 | isa = XCBuildConfiguration; 398 | buildSettings = { 399 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 400 | INFOPLIST_FILE = AnimatedBubbleTest/Info.plist; 401 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; 402 | PRODUCT_NAME = "$(TARGET_NAME)"; 403 | }; 404 | name = Release; 405 | }; 406 | 63A27F121B88342800F8197E /* Debug */ = { 407 | isa = XCBuildConfiguration; 408 | buildSettings = { 409 | BUNDLE_LOADER = "$(TEST_HOST)"; 410 | FRAMEWORK_SEARCH_PATHS = ( 411 | "$(SDKROOT)/Developer/Library/Frameworks", 412 | "$(inherited)", 413 | ); 414 | GCC_PREPROCESSOR_DEFINITIONS = ( 415 | "DEBUG=1", 416 | "$(inherited)", 417 | ); 418 | INFOPLIST_FILE = AnimatedBubbleTestTests/Info.plist; 419 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 420 | PRODUCT_NAME = "$(TARGET_NAME)"; 421 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AnimatedBubbleTest.app/AnimatedBubbleTest"; 422 | }; 423 | name = Debug; 424 | }; 425 | 63A27F131B88342800F8197E /* Release */ = { 426 | isa = XCBuildConfiguration; 427 | buildSettings = { 428 | BUNDLE_LOADER = "$(TEST_HOST)"; 429 | FRAMEWORK_SEARCH_PATHS = ( 430 | "$(SDKROOT)/Developer/Library/Frameworks", 431 | "$(inherited)", 432 | ); 433 | INFOPLIST_FILE = AnimatedBubbleTestTests/Info.plist; 434 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; 435 | PRODUCT_NAME = "$(TARGET_NAME)"; 436 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AnimatedBubbleTest.app/AnimatedBubbleTest"; 437 | }; 438 | name = Release; 439 | }; 440 | /* End XCBuildConfiguration section */ 441 | 442 | /* Begin XCConfigurationList section */ 443 | 63A27EE61B88342800F8197E /* Build configuration list for PBXProject "AnimatedBubbleTest" */ = { 444 | isa = XCConfigurationList; 445 | buildConfigurations = ( 446 | 63A27F0C1B88342800F8197E /* Debug */, 447 | 63A27F0D1B88342800F8197E /* Release */, 448 | ); 449 | defaultConfigurationIsVisible = 0; 450 | defaultConfigurationName = Release; 451 | }; 452 | 63A27F0E1B88342800F8197E /* Build configuration list for PBXNativeTarget "AnimatedBubbleTest" */ = { 453 | isa = XCConfigurationList; 454 | buildConfigurations = ( 455 | 63A27F0F1B88342800F8197E /* Debug */, 456 | 63A27F101B88342800F8197E /* Release */, 457 | ); 458 | defaultConfigurationIsVisible = 0; 459 | defaultConfigurationName = Release; 460 | }; 461 | 63A27F111B88342800F8197E /* Build configuration list for PBXNativeTarget "AnimatedBubbleTestTests" */ = { 462 | isa = XCConfigurationList; 463 | buildConfigurations = ( 464 | 63A27F121B88342800F8197E /* Debug */, 465 | 63A27F131B88342800F8197E /* Release */, 466 | ); 467 | defaultConfigurationIsVisible = 0; 468 | defaultConfigurationName = Release; 469 | }; 470 | /* End XCConfigurationList section */ 471 | }; 472 | rootObject = 63A27EE31B88342800F8197E /* Project object */; 473 | } 474 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/22. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | 16 | @end 17 | 18 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/22. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import "AppDelegate.h" 10 | 11 | @interface AppDelegate () 12 | 13 | @end 14 | 15 | @implementation AppDelegate 16 | 17 | 18 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { 19 | // Override point for customization after application launch. 20 | return YES; 21 | } 22 | 23 | - (void)applicationWillResignActive:(UIApplication *)application { 24 | // 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. 25 | // 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. 26 | } 27 | 28 | - (void)applicationDidEnterBackground:(UIApplication *)application { 29 | // 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. 30 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 31 | } 32 | 33 | - (void)applicationWillEnterForeground:(UIApplication *)application { 34 | // 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. 35 | } 36 | 37 | - (void)applicationDidBecomeActive:(UIApplication *)application { 38 | // 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. 39 | } 40 | 41 | - (void)applicationWillTerminate:(UIApplication *)application { 42 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 43 | } 44 | 45 | @end 46 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/Base.lproj/LaunchScreen.xib: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 20 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/Base.lproj/Main.storyboard: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 39 | 46 | 53 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/BubbleView/BubbleLayer.h: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleLayer.h 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/23. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | struct CGSquare{ 13 | CGPoint pointA; 14 | CGPoint pointB; 15 | CGPoint pointC; 16 | CGPoint pointD; 17 | }; 18 | 19 | @interface BubbleLayer : CALayer 20 | 21 | @property(nonatomic,strong)UIColor *color; 22 | 23 | @property(nonatomic,assign)CGFloat bubbleSize; 24 | 25 | @property(nonatomic,assign)CGFloat scaleRatio; 26 | 27 | 28 | @property(nonatomic,strong)NSArray *durations; 29 | 30 | 31 | - (void)setDesPoint:(CGPoint)desPoint; 32 | 33 | @end 34 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/BubbleView/BubbleLayer.m: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleLayer.m 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/23. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import "BubbleLayer.h" 10 | #import "KYSpringLayerAnimation.h" 11 | #import "SCCircleMath.h" 12 | 13 | @interface BubbleLayer() 14 | 15 | @property(nonatomic,assign)CGFloat angle; 16 | @property(nonatomic,assign)CGRect currentRect; 17 | @property(nonatomic,assign)CGPoint desPoint; 18 | 19 | @property(nonatomic,assign)CGFloat factor1; 20 | @property(nonatomic,assign)CGFloat factor2; 21 | 22 | 23 | @end 24 | 25 | 26 | @implementation BubbleLayer{ 27 | struct CGSquare square; 28 | } 29 | 30 | -(id)init{ 31 | self = [super init]; 32 | if (self) { 33 | _color = [UIColor blueColor]; 34 | _currentRect = CGRectMake(50, 50, 100, 100); 35 | _factor1 = 0; 36 | _factor2 = 0; 37 | _scaleRatio = 0.6; 38 | _bubbleSize = 100; 39 | _durations = @[@(0.6),@(0.8),@(0.3)]; 40 | } 41 | return self; 42 | } 43 | 44 | - (void)setFrame:(CGRect)frame 45 | { 46 | [super setFrame:frame]; 47 | _currentRect = CGRectMake(frame.size.width - _bubbleSize/2,frame.size.height - _bubbleSize/2, _bubbleSize, _bubbleSize); 48 | } 49 | 50 | - (void)setBubbleSize:(CGFloat)bubbleSize 51 | { 52 | _bubbleSize = bubbleSize; 53 | _currentRect = CGRectMake(self.frame.size.width - _bubbleSize/2,self.frame.size.height - _bubbleSize/2, _bubbleSize, _bubbleSize); 54 | [self setNeedsDisplay]; 55 | } 56 | 57 | - (void)setColor:(UIColor *)color 58 | { 59 | _color = color; 60 | [self setNeedsDisplay]; 61 | } 62 | 63 | - (id)initWithLayer:(BubbleLayer *)layer{ 64 | self = [super initWithLayer:layer]; 65 | if (self) { 66 | self.currentRect = layer.currentRect; 67 | self.factor1 = layer.factor1; 68 | self.factor2 = layer.factor2; 69 | self.angle = layer.angle; 70 | self.color = layer.color; 71 | self.durations = layer.durations; 72 | } 73 | return self; 74 | } 75 | 76 | - (void)setDesPoint:(CGPoint)desPoint 77 | { 78 | _desPoint = desPoint; 79 | 80 | _angle = atanf((desPoint.y - self.position.y)/(desPoint.x - self.position.x)); 81 | 82 | [self triggleAnimation]; 83 | } 84 | 85 | - (void)drawInContext:(CGContextRef)ctx{ 86 | [super drawInContext:ctx]; 87 | 88 | CGFloat extra1 = (self.currentRect.size.width * 2 / 5) * _factor1; 89 | 90 | CGFloat extra2 = (self.currentRect.size.width * 2 / 5) * _factor2; 91 | 92 | CGFloat radius1 = _currentRect.size.width/2 - extra1; //短边 93 | CGFloat radius2 = _currentRect.size.width/2 - extra2; //长边 94 | 95 | CGFloat offset = self.currentRect.size.width / 3.6 - extra1 / 1.8; //设置3.6 出来的弧度最像圆形 96 | 97 | square.pointB = [SCCircleMath caculatePointFromAngle:_angle CirCleCenter:self.position cirCleRadius:radius1]; 98 | square.pointC = [SCCircleMath caculatePointFromAngle:_angle + M_PI_4*2 CirCleCenter:self.position cirCleRadius:radius2]; 99 | square.pointD = [SCCircleMath caculatePointFromAngle:_angle + M_PI_4*4 CirCleCenter:self.position cirCleRadius:radius1]; 100 | square.pointA = [SCCircleMath caculatePointFromAngle:_angle + M_PI_4*6 CirCleCenter:self.position cirCleRadius:radius1]; 101 | 102 | CGFloat sinValue = offset * sinf(_angle); 103 | CGFloat cosValue = offset * cosf(_angle); 104 | 105 | CGPoint c1 = CGPointMake(square.pointA.x + sinValue, square.pointA.y - cosValue); 106 | CGPoint c2 = CGPointMake(square.pointB.x - cosValue, square.pointB.y - sinValue); 107 | 108 | CGPoint c3 = CGPointMake(square.pointB.x + cosValue, square.pointB.y + sinValue); 109 | CGPoint c4 = CGPointMake(square.pointC.x + sinValue, square.pointC.y - cosValue); 110 | 111 | CGPoint c5 = CGPointMake(square.pointC.x - sinValue, square.pointC.y + cosValue); 112 | CGPoint c6 = CGPointMake(square.pointD.x + cosValue, square.pointD.y + sinValue); 113 | 114 | CGPoint c7 = CGPointMake(square.pointD.x - cosValue, square.pointD.y - sinValue); 115 | CGPoint c8 = CGPointMake(square.pointA.x - sinValue, square.pointA.y + cosValue); 116 | 117 | UIBezierPath* ovalPath = [UIBezierPath bezierPath]; 118 | 119 | [ovalPath moveToPoint: square.pointA]; 120 | [ovalPath addCurveToPoint:square.pointB controlPoint1:c1 controlPoint2:c2]; 121 | [ovalPath addCurveToPoint:square.pointC controlPoint1:c3 controlPoint2:c4]; 122 | [ovalPath addCurveToPoint:square.pointD controlPoint1:c5 controlPoint2:c6]; 123 | [ovalPath addCurveToPoint:square.pointA controlPoint1:c7 controlPoint2:c8]; 124 | 125 | [ovalPath closePath]; 126 | 127 | CGContextAddPath(ctx, ovalPath.CGPath); 128 | CGContextSetFillColorWithColor(ctx, self.color.CGColor); 129 | CGContextFillPath(ctx); 130 | } 131 | 132 | 133 | +(BOOL)needsDisplayForKey:(NSString *)key{ 134 | if ([key isEqual:@"factor1"] || [key isEqual:@"factor2"]) { 135 | return YES; 136 | } 137 | 138 | return [super needsDisplayForKey:key]; 139 | } 140 | 141 | -(void)triggleAnimation{ 142 | //Spring animation 143 | CAKeyframeAnimation *anim = [[KYSpringLayerAnimation sharedAnimManager]createSpringAnima:@"factor1" duration:[self.durations[0] floatValue] usingSpringWithDamping:0.5 initialSpringVelocity:3 fromValue:@(0) toValue:@(1 - self.scaleRatio)]; 144 | anim.removedOnCompletion = YES; 145 | self.factor1 = 1 - self.scaleRatio; 146 | [self addAnimation:anim forKey:@"triggleAnimation"]; 147 | [self performSelector:@selector(roundAnimation) withObject:nil afterDelay:[self.durations[2] floatValue]]; 148 | } 149 | 150 | -(void)roundAnimation{ 151 | 152 | //Spring animation 153 | CAKeyframeAnimation *anim = [[KYSpringLayerAnimation sharedAnimManager]createSpringAnima:@"factor2" duration:[self.durations[1] floatValue] usingSpringWithDamping:0.5 initialSpringVelocity:2.5 fromValue:@(0) toValue:@(1 - self.scaleRatio)]; 154 | self.factor2 = 1 - self.scaleRatio; 155 | [self addAnimation:anim forKey:@"restoreAnimation"]; 156 | } 157 | 158 | @end 159 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/BubbleView/BubbleView.h: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleView.h 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/23. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "BubbleLayer.h" 11 | 12 | @interface BubbleView : UIView 13 | 14 | @property (nonatomic,assign) CGPoint desPoint; 15 | @property (nonatomic,strong) BubbleLayer *bubbleLayer; 16 | 17 | @end 18 | 19 | 20 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/BubbleView/BubbleView.m: -------------------------------------------------------------------------------- 1 | // 2 | // BubbleView.m 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/23. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import "BubbleView.h" 10 | #import "KYSpringLayerAnimation.h" 11 | 12 | @implementation BubbleView 13 | 14 | - (void)initTheView 15 | { 16 | _bubbleLayer = [BubbleLayer layer]; 17 | CGRect rect = self.bounds; 18 | [self.layer addSublayer:_bubbleLayer]; 19 | 20 | _bubbleLayer.frame = rect; 21 | _bubbleLayer.bubbleSize = 100; 22 | _bubbleLayer.color = [UIColor blueColor]; 23 | _bubbleLayer.scaleRatio = 0.7; 24 | 25 | UITapGestureRecognizer *tapGr = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(tap:)]; 26 | [self addGestureRecognizer:tapGr]; 27 | } 28 | 29 | 30 | -(void)tap:(UITapGestureRecognizer *)tapGr 31 | { 32 | tapGr.enabled = NO; 33 | 34 | CGRect frame = self.frame; 35 | frame.origin = CGPointZero; 36 | 37 | CGPoint originalcenter = self.center; 38 | 39 | CGPoint center = self.desPoint; 40 | 41 | [_bubbleLayer setDesPoint:[self.superview convertPoint:center toView:self]]; 42 | 43 | CAKeyframeAnimation *anim = [[KYSpringLayerAnimation sharedAnimManager]createSpringAnima:@"position" duration:1.0 usingSpringWithDamping:0.9 initialSpringVelocity:1 fromValue:[NSValue valueWithCGPoint:originalcenter] toValue:[NSValue valueWithCGPoint:center]]; 44 | self.layer.position= center; 45 | [self.layer addAnimation:anim forKey:@"move"]; 46 | } 47 | 48 | - (id)init 49 | { 50 | self = [super init]; 51 | if (self) { 52 | [self initTheView]; 53 | } 54 | return self; 55 | } 56 | 57 | - (id)initWithCoder:(NSCoder *)aDecoder 58 | { 59 | self = [super initWithCoder:aDecoder]; 60 | if (self) { 61 | [self initTheView]; 62 | } 63 | return self; 64 | } 65 | 66 | -(instancetype)initWithFrame:(CGRect)frame 67 | { 68 | self = [super initWithFrame:frame]; 69 | if (self) { 70 | [self initTheView]; 71 | } 72 | return self; 73 | } 74 | 75 | 76 | @end 77 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/Images.xcassets/AppIcon.appiconset/Contents.json: -------------------------------------------------------------------------------- 1 | { 2 | "images" : [ 3 | { 4 | "idiom" : "iphone", 5 | "size" : "29x29", 6 | "scale" : "2x" 7 | }, 8 | { 9 | "idiom" : "iphone", 10 | "size" : "29x29", 11 | "scale" : "3x" 12 | }, 13 | { 14 | "idiom" : "iphone", 15 | "size" : "40x40", 16 | "scale" : "2x" 17 | }, 18 | { 19 | "idiom" : "iphone", 20 | "size" : "40x40", 21 | "scale" : "3x" 22 | }, 23 | { 24 | "idiom" : "iphone", 25 | "size" : "60x60", 26 | "scale" : "2x" 27 | }, 28 | { 29 | "idiom" : "iphone", 30 | "size" : "60x60", 31 | "scale" : "3x" 32 | } 33 | ], 34 | "info" : { 35 | "version" : 1, 36 | "author" : "xcode" 37 | } 38 | } -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | sgcy.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | APPL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | LSRequiresIPhoneOS 24 | 25 | UILaunchStoryboardName 26 | LaunchScreen 27 | UIMainStoryboardFile 28 | Main 29 | UIRequiredDeviceCapabilities 30 | 31 | armv7 32 | 33 | UISupportedInterfaceOrientations 34 | 35 | UIInterfaceOrientationPortrait 36 | UIInterfaceOrientationLandscapeLeft 37 | UIInterfaceOrientationLandscapeRight 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/KYSpringLayerAnimation.h: -------------------------------------------------------------------------------- 1 | // 2 | // KYSpringLayerAnimation.h 3 | // KYAnimatedPageControl-Demo 4 | // 5 | // Created by Kitten Yang on 6/10/15. 6 | // Copyright (c) 2015 Kitten Yang. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface KYSpringLayerAnimation : NSObject 13 | 14 | 15 | +(instancetype)sharedAnimManager; 16 | 17 | //Normal Anim -- 线性函数 18 | -(CAKeyframeAnimation *)createBasicAnima:(NSString *)keypath duration:(CFTimeInterval)duration fromValue:(id)fromValue toValue:(id)toValue; 19 | 20 | //Spring Anim -- 弹性曲线 21 | -(CAKeyframeAnimation *)createSpringAnima:(NSString *)keypath duration:(CFTimeInterval)duration usingSpringWithDamping:(CGFloat)damping initialSpringVelocity:(CGFloat)velocity fromValue:(id)fromValue toValue:(id)toValue; 22 | 23 | 24 | //Curve Anim -- 二次平滑抛物函数 25 | -(CAKeyframeAnimation *)createCurveAnima:(NSString *)keypath duration:(CFTimeInterval)duration fromValue:(id)fromValue toValue:(id)toValue; 26 | 27 | //Curve Anim -- 抛到一半的二次平滑抛物函数 28 | -(CAKeyframeAnimation *)createHalfCurveAnima:(NSString *)keypath duration:(CFTimeInterval)duration fromValue:(id)fromValue toValue:(id)toValue; 29 | 30 | 31 | @end 32 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/KYSpringLayerAnimation.m: -------------------------------------------------------------------------------- 1 | // 2 | // KYSpringLayerAnimation.m 3 | // KYAnimatedPageControl-Demo 4 | // 5 | // Created by Kitten Yang on 6/10/15. 6 | // Copyright (c) 2015 Kitten Yang. All rights reserved. 7 | // 8 | 9 | #import "KYSpringLayerAnimation.h" 10 | 11 | @implementation KYSpringLayerAnimation 12 | 13 | +(instancetype)sharedAnimManager{ 14 | 15 | static KYSpringLayerAnimation *animManager = nil; 16 | static dispatch_once_t predicate; 17 | dispatch_once(&predicate, ^{ 18 | animManager = [[KYSpringLayerAnimation alloc]init]; 19 | }); 20 | return animManager; 21 | } 22 | 23 | 24 | #pragma mark -- Main Class Methods 25 | 26 | -(CAKeyframeAnimation *)createBasicAnima:(NSString *)keypath duration:(CFTimeInterval)duration fromValue:(id)fromValue toValue:(id)toValue{ 27 | 28 | 29 | CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:keypath]; 30 | anim.values = [self basicAnimationValues:fromValue toValue:toValue duration:duration]; 31 | anim.duration = duration; 32 | anim.fillMode = kCAFillModeForwards; 33 | anim.removedOnCompletion = NO; 34 | 35 | return anim; 36 | } 37 | 38 | -(CAKeyframeAnimation *)createSpringAnima:(NSString *)keypath duration:(CFTimeInterval)duration usingSpringWithDamping:(CGFloat)damping initialSpringVelocity:(CGFloat)velocity fromValue:(id)fromValue toValue:(id)toValue{ 39 | 40 | CGFloat dampingFactor = 10.0; 41 | CGFloat velocityFactor = 10.0; 42 | NSMutableArray *values = [self springAnimationValues:fromValue toValue:toValue usingSpringWithDamping:damping * dampingFactor initialSpringVelocity:velocity * velocityFactor duration:duration]; 43 | 44 | CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:keypath]; 45 | anim.values = values; 46 | anim.duration = duration; 47 | anim.fillMode = kCAFillModeForwards; 48 | anim.removedOnCompletion = NO; 49 | 50 | return anim; 51 | } 52 | 53 | 54 | -(CAKeyframeAnimation *)createCurveAnima:(NSString *)keypath duration:(CFTimeInterval)duration fromValue:(id)fromValue toValue:(id)toValue{ 55 | CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:keypath]; 56 | anim.values = [self curveAnimationValues:fromValue toValue:toValue duration:duration]; 57 | anim.duration = duration; 58 | anim.fillMode = kCAFillModeForwards; 59 | anim.removedOnCompletion = NO; 60 | 61 | return anim; 62 | } 63 | 64 | 65 | -(CAKeyframeAnimation *)createHalfCurveAnima:(NSString *)keypath duration:(CFTimeInterval)duration fromValue:(id)fromValue toValue:(id)toValue{ 66 | 67 | CAKeyframeAnimation *anim = [CAKeyframeAnimation animationWithKeyPath:keypath]; 68 | anim.values = [self halfCurveAnimationValues:fromValue toValue:toValue duration:duration]; 69 | anim.duration = duration; 70 | anim.fillMode = kCAFillModeForwards; 71 | anim.removedOnCompletion = NO; 72 | 73 | return anim; 74 | 75 | } 76 | 77 | 78 | #pragma mark -- Helper Methods 79 | -(NSMutableArray *) basicAnimationValues:(id)fromValue toValue:(id)toValue duration:(CGFloat)duration{ 80 | 81 | NSInteger numOfFrames = duration * 60; 82 | NSMutableArray *values = [NSMutableArray arrayWithCapacity:numOfFrames]; 83 | for (NSInteger i = 0; i < numOfFrames; i++) { 84 | [values addObject:@(0.0)]; 85 | } 86 | 87 | CGFloat diff = [toValue floatValue] - [fromValue floatValue]; 88 | for (NSInteger frame = 0; frame 10 | #import 11 | 12 | @interface SCCircleMath : NSObject 13 | 14 | /*! 15 |     @brief 根据 圆弧的半径 和 弧上的点到圆垂直中线的距离 来计算弧上点所在半径与垂直线的夹角 16 |    17 |     @param circleRadius 圆弧半径 18 |    19 | @param distance 弧上的点到圆垂直中线的距离 20 | 21 |     @return CGFloat 弧上点所在半径与垂直线的夹角 22 | */ 23 | + (CGFloat)caculaterRotateAngleFromCircleRadius:(CGFloat)circleRadius 24 | distance:(CGFloat)distance; 25 | 26 | 27 | 28 | /*! 29 |     @brief 已知 圆弧中心 和 圆弧半径 ,根据弧上点X坐标来计算Y坐标 30 |    31 |     @param  xPosition  X坐标 32 |    33 | @param center 圆弧中心 34 | 35 | @param radius 圆弧半径 36 | 37 |     @return CGFloat Y坐标 38 | */ 39 | + (CGFloat)caculateYPositionFromXPoision:(CGFloat)xPosition 40 | CirCleCenter:(CGPoint)center 41 | cirCleRadius:(CGFloat)radius; 42 | 43 | 44 | 45 | 46 | /*! 47 |     @brief 已知 点A 和 点B,求两点中垂线 48 |    49 | @param xPosition 中垂线的X坐标 50 | 51 |     @return CGFloat 中垂线的Y坐标 52 | */ 53 | + (CGFloat)caculateLineFromPointA:(CGPoint)pointA 54 | andPointB:(CGPoint)pointB 55 | xPosition:(CGFloat)xPosition; 56 | 57 | 58 | 59 | + (CGPoint)caculatePointFromAngle:(CGFloat)angle 60 | CirCleCenter:(CGPoint)center 61 | cirCleRadius:(CGFloat)radius; 62 | 63 | 64 | 65 | @end 66 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/SCCircleMath.m: -------------------------------------------------------------------------------- 1 | // 2 | // GXCircleMath.m 3 | // GXArcView 4 | // 5 | // Created by sgcy on 15/7/22. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import "SCCircleMath.h" 10 | @implementation SCCircleMath 11 | 12 | + (CGFloat)caculaterRotateAngleFromCircleRadius:(CGFloat)circleRadius 13 | distance:(CGFloat)distance 14 | { 15 | return asinf(distance/circleRadius); 16 | } 17 | 18 | + (CGFloat)caculateYPositionFromXPoision:(CGFloat)xPosition 19 | CirCleCenter:(CGPoint)center 20 | cirCleRadius:(CGFloat)radius 21 | { 22 | return sqrt(radius*radius - (xPosition - center.x)*(xPosition - center.x)) + center.y; 23 | } 24 | 25 | + (CGFloat)caculateLineFromPointA:(CGPoint)pointA 26 | andPointB:(CGPoint)pointB 27 | xPosition:(CGFloat)xPosition 28 | { 29 | return (pointA.y + pointB.y)/2 - ((pointB.x - pointA.x)/(pointB.y - pointA.y)) * (xPosition - (pointA.x + pointB.x)/2); 30 | } 31 | 32 | + (CGPoint)caculatePointFromAngle:(CGFloat)angle 33 | CirCleCenter:(CGPoint)center 34 | cirCleRadius:(CGFloat)radius 35 | { 36 | CGFloat x = center.x + radius * sinf(angle); 37 | CGFloat y = center.y - radius * cosf(angle); 38 | return CGPointMake(x, y); 39 | } 40 | 41 | @end 42 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/ViewController.h: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.h 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/22. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import 10 | 11 | @interface ViewController : UIViewController 12 | 13 | 14 | @end 15 | 16 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/ViewController.m: -------------------------------------------------------------------------------- 1 | // 2 | // ViewController.m 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/22. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import "ViewController.h" 10 | #import "BubbleView.h" 11 | 12 | @interface ViewController () 13 | 14 | @property (strong, nonatomic)BubbleView *animatedView; 15 | @property (weak, nonatomic) IBOutlet UISlider *slider1; 16 | @property (weak, nonatomic) IBOutlet UISlider *slider2; 17 | @property (weak, nonatomic) IBOutlet UISlider *slider3; 18 | 19 | @property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *labels; 20 | @end 21 | 22 | @implementation ViewController 23 | - (void)viewDidLoad { 24 | [super viewDidLoad]; 25 | 26 | _animatedView = [[BubbleView alloc]initWithFrame:CGRectMake(self.view.frame.size.width - 200, self.view.frame.size.height - 200, 200, 200)]; 27 | [self.view addSubview:self.animatedView]; 28 | 29 | _animatedView.layer.masksToBounds = NO; 30 | _animatedView.desPoint = CGPointMake(_animatedView.frame.size.width/2, _animatedView.frame.size.height/2); 31 | } 32 | - (IBAction)reset:(id)sender { 33 | [_animatedView removeFromSuperview]; 34 | 35 | _animatedView = [[BubbleView alloc]initWithFrame:CGRectMake(self.view.frame.size.width - 200, self.view.frame.size.height - 200, 200, 200)]; 36 | [self.view addSubview:self.animatedView]; 37 | _animatedView.desPoint = CGPointMake(_animatedView.frame.size.width/2, _animatedView.frame.size.height/2); 38 | _animatedView.bubbleLayer.durations = @[@(self.slider1.value),@(self.slider2.value),@(self.slider3.value)]; 39 | } 40 | - (IBAction)sliderDidSlider1:(id)sender { 41 | [self.labels enumerateObjectsUsingBlock:^(id obj, NSUInteger idx, BOOL *stop) { 42 | UILabel *label = (UILabel *)obj; 43 | UISlider *slider = @[self.slider1,self.slider2,self.slider3][idx]; 44 | label.text = [NSString stringWithFormat:@"%.2f",slider.value]; 45 | }]; 46 | } 47 | @end 48 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTest/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // AnimatedBubbleTest 4 | // 5 | // Created by sgcy on 15/8/22. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import "AppDelegate.h" 11 | 12 | int main(int argc, char * argv[]) { 13 | @autoreleasepool { 14 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTestTests/AnimatedBubbleTestTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // AnimatedBubbleTestTests.m 3 | // AnimatedBubbleTestTests 4 | // 5 | // Created by sgcy on 15/8/22. 6 | // Copyright (c) 2015年 sgcy. All rights reserved. 7 | // 8 | 9 | #import 10 | #import 11 | 12 | @interface AnimatedBubbleTestTests : XCTestCase 13 | 14 | @end 15 | 16 | @implementation AnimatedBubbleTestTests 17 | 18 | - (void)setUp { 19 | [super setUp]; 20 | // Put setup code here. This method is called before the invocation of each test method in the class. 21 | } 22 | 23 | - (void)tearDown { 24 | // Put teardown code here. This method is called after the invocation of each test method in the class. 25 | [super tearDown]; 26 | } 27 | 28 | - (void)testExample { 29 | // This is an example of a functional test case. 30 | XCTAssert(YES, @"Pass"); 31 | } 32 | 33 | - (void)testPerformanceExample { 34 | // This is an example of a performance test case. 35 | [self measureBlock:^{ 36 | // Put the code you want to measure the time of here. 37 | }]; 38 | } 39 | 40 | @end 41 | -------------------------------------------------------------------------------- /AnimatedBubbleTest/AnimatedBubbleTestTests/Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | $(EXECUTABLE_NAME) 9 | CFBundleIdentifier 10 | sgcy.$(PRODUCT_NAME:rfc1034identifier) 11 | CFBundleInfoDictionaryVersion 12 | 6.0 13 | CFBundleName 14 | $(PRODUCT_NAME) 15 | CFBundlePackageType 16 | BNDL 17 | CFBundleShortVersionString 18 | 1.0 19 | CFBundleSignature 20 | ???? 21 | CFBundleVersion 22 | 1 23 | 24 | 25 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2015 lilidan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | 23 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # StickyBallView 2 | An iOS round view with sticky effect. 3 | ## Effect 4 | 5 | 6 | ![](https://github.com/lilidan/StickyBallView/blob/master/ScreenShot.gif) 7 | 8 | ## Inspired by 9 | 10 | [This Design](http://www.appdesignserved.co/gallery/Workout-Book-workout-tracking-app-concept/27399145) 11 | 12 | ![](https://m2.behance.net/rendition/pm/27399145/disp/ed59b0f8c4caae0f5d8d24fbf9f47738.gif) 13 | 14 | I learned how to do this from [this Blog](http://kittenyang.com/deformationandgooey/) 15 | 16 | And I use some code from [KYAnimatedPageControl](https://github.com/KittenYang/KYAnimatedPageControl/) 17 | 18 | 19 | 20 | 21 | -------------------------------------------------------------------------------- /ScreenShot.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lilidan/StickyBallView/eff60656e2adc9bea3d4d5dfbf6eae0a6ffaa36a/ScreenShot.gif --------------------------------------------------------------------------------