├── .gitignore ├── LICENSE ├── README.md ├── UIDynamicExample.xcodeproj ├── project.pbxproj └── project.xcworkspace │ └── contents.xcworkspacedata ├── UIDynamicExample ├── AppDelegate.h ├── AppDelegate.m ├── Images.xcassets │ ├── AppIcon.appiconset │ │ └── Contents.json │ └── LaunchImage.launchimage │ │ └── Contents.json ├── MainViewController.h ├── MainViewController.m ├── UIDynamicExample-Info.plist ├── UIDynamicExample-Prefix.pch ├── ViewControllers │ ├── GeneralViewController.h │ └── GeneralViewController.m ├── Views │ ├── AdvancedAttachmentView.h │ ├── AdvancedAttachmentView.m │ ├── AttachmentView.h │ ├── AttachmentView.m │ ├── BallView.h │ ├── BallView.m │ ├── BaseViewWithBall.h │ ├── BaseViewWithBall.m │ ├── CollisionView.h │ ├── CollisionView.m │ ├── GravityView.h │ ├── GravityView.m │ ├── PushView.h │ ├── PushView.m │ ├── SnapView.h │ ├── SnapView.m │ ├── UIView+Category.h │ └── UIView+Category.m ├── bang.png ├── en.lproj │ └── InfoPlist.strings └── main.m ├── UIDynamicExampleTests ├── UIDynamicExampleTests-Info.plist ├── UIDynamicExampleTests.m └── en.lproj │ └── InfoPlist.strings └── snapshots ├── advanced_attachment.gif ├── attachment.gif ├── collision.gif ├── gravity.gif ├── push.gif └── snap.gif /.gitignore: -------------------------------------------------------------------------------- 1 | # Xcode 2 | .DS_Store 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 | profile 14 | *.moved-aside 15 | DerivedData 16 | .idea/ 17 | *.hmap 18 | *.xccheckout 19 | 20 | #CocoaPods 21 | Pods -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "{}" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright {yyyy} {name of copyright owner} 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | 203 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | UIDynamicExample 2 | ================ 3 | 4 | This project aims to provide examples of UIDynamic behaviour of iOS7, including: 5 | 6 | - Gravity 7 | - Collision 8 | - Attachment 9 | - Snap 10 | - Push 11 | 12 | Please see the gifs below for more information: 13 | 14 | ###Gravity 15 | 16 | 17 | 18 | ###Collision 19 | 20 | 21 | 22 | ###Attachment 23 | 24 | 25 | 26 | ###Advanced attachment 27 | 28 | 29 | 30 | ###Snap 31 | 32 | 33 | 34 | ###Push 35 | 36 | 37 | 38 | 39 | ##References: 40 | 41 | http://www.shinobicontrols.com/blog/posts/2013/09/19/ios7-day-by-day-day-0-uikit-dynamics/ 42 | 43 | http://www.raywenderlich.com/50197/uikit-dynamics-tutorial 44 | 45 | http://www.teehanlax.com/blog/introduction-to-uikit-dynamics/ 46 | 47 | http://onevcat.com/2013/06/uikit-dynamics-started/ 48 | -------------------------------------------------------------------------------- /UIDynamicExample.xcodeproj/project.pbxproj: -------------------------------------------------------------------------------- 1 | // !$*UTF8*$! 2 | { 3 | archiveVersion = 1; 4 | classes = { 5 | }; 6 | objectVersion = 46; 7 | objects = { 8 | 9 | /* Begin PBXBuildFile section */ 10 | 368670CA0C009F0D1F059C7F /* bang.png in Resources */ = {isa = PBXBuildFile; fileRef = 36867277A3CBA5B51467245A /* bang.png */; }; 11 | 36867476A5A2229142E0D25A /* BaseViewWithBall.m in Sources */ = {isa = PBXBuildFile; fileRef = 368677B8ACB8306D4A48C8F9 /* BaseViewWithBall.m */; }; 12 | 368674F1613E5B8466D7DEA9 /* AdvancedAttachmentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 3686777677F30452D18AC00B /* AdvancedAttachmentView.m */; }; 13 | 3686759D50AAFEBEA0786997 /* BallView.m in Sources */ = {isa = PBXBuildFile; fileRef = 36867D45EBFDA080F4EF81B7 /* BallView.m */; }; 14 | 368675E8F0104D18D8B3C91F /* GravityView.m in Sources */ = {isa = PBXBuildFile; fileRef = 36867320683C7687BA6B208F /* GravityView.m */; }; 15 | 3686775E1916DCD6540F2499 /* MainViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 368671A593EC171709730665 /* MainViewController.m */; }; 16 | 368677F7E5305344700D83B3 /* UIView+Category.m in Sources */ = {isa = PBXBuildFile; fileRef = 36867B35E773912E92684883 /* UIView+Category.m */; }; 17 | 3686795E2E8F3BD26C14BD34 /* PushView.m in Sources */ = {isa = PBXBuildFile; fileRef = 368676DE8D250DABA0520C5B /* PushView.m */; }; 18 | 36867B128C249E5B2ECC54A0 /* AttachmentView.m in Sources */ = {isa = PBXBuildFile; fileRef = 368671F44B8F18A61F0BD490 /* AttachmentView.m */; }; 19 | 36867BF87EEA7BF2A94FC3DD /* CollisionView.m in Sources */ = {isa = PBXBuildFile; fileRef = 36867B4262C15CCD89BF5349 /* CollisionView.m */; }; 20 | 36867F489959D69986906F7A /* SnapView.m in Sources */ = {isa = PBXBuildFile; fileRef = 368677AFB50647B915E69099 /* SnapView.m */; }; 21 | 36867FAF75CAC11275429C03 /* GeneralViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 36867E83A6D2325CEE84E199 /* GeneralViewController.m */; }; 22 | 49C3E9D3182C3870002D8841 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49C3E9D2182C3870002D8841 /* Foundation.framework */; }; 23 | 49C3E9D5182C3870002D8841 /* CoreGraphics.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49C3E9D4182C3870002D8841 /* CoreGraphics.framework */; }; 24 | 49C3E9D7182C3870002D8841 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49C3E9D6182C3870002D8841 /* UIKit.framework */; }; 25 | 49C3E9DD182C3870002D8841 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 49C3E9DB182C3870002D8841 /* InfoPlist.strings */; }; 26 | 49C3E9DF182C3870002D8841 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 49C3E9DE182C3870002D8841 /* main.m */; }; 27 | 49C3E9E3182C3870002D8841 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 49C3E9E2182C3870002D8841 /* AppDelegate.m */; }; 28 | 49C3E9E5182C3870002D8841 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 49C3E9E4182C3870002D8841 /* Images.xcassets */; }; 29 | 49C3E9EC182C3870002D8841 /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49C3E9EB182C3870002D8841 /* XCTest.framework */; }; 30 | 49C3E9ED182C3870002D8841 /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49C3E9D2182C3870002D8841 /* Foundation.framework */; }; 31 | 49C3E9EE182C3870002D8841 /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 49C3E9D6182C3870002D8841 /* UIKit.framework */; }; 32 | 49C3E9F6182C3870002D8841 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 49C3E9F4182C3870002D8841 /* InfoPlist.strings */; }; 33 | 49C3E9F8182C3870002D8841 /* UIDynamicExampleTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 49C3E9F7182C3870002D8841 /* UIDynamicExampleTests.m */; }; 34 | /* End PBXBuildFile section */ 35 | 36 | /* Begin PBXContainerItemProxy section */ 37 | 49C3E9EF182C3870002D8841 /* PBXContainerItemProxy */ = { 38 | isa = PBXContainerItemProxy; 39 | containerPortal = 49C3E9C7182C3870002D8841 /* Project object */; 40 | proxyType = 1; 41 | remoteGlobalIDString = 49C3E9CE182C3870002D8841; 42 | remoteInfo = UIDynamicExample; 43 | }; 44 | /* End PBXContainerItemProxy section */ 45 | 46 | /* Begin PBXFileReference section */ 47 | 3686701A253292024D2B34B0 /* BaseViewWithBall.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BaseViewWithBall.h; sourceTree = ""; }; 48 | 36867196D14AE983965C51FC /* MainViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = MainViewController.h; sourceTree = ""; }; 49 | 368671A593EC171709730665 /* MainViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = MainViewController.m; sourceTree = ""; }; 50 | 368671F44B8F18A61F0BD490 /* AttachmentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AttachmentView.m; sourceTree = ""; }; 51 | 36867277A3CBA5B51467245A /* bang.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = bang.png; sourceTree = ""; }; 52 | 36867320683C7687BA6B208F /* GravityView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GravityView.m; sourceTree = ""; }; 53 | 368673E18CE48D8F215866EF /* GravityView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GravityView.h; sourceTree = ""; }; 54 | 3686742482EACF6B0AFCD013 /* CollisionView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CollisionView.h; sourceTree = ""; }; 55 | 368674C3276016F775A49EB5 /* SnapView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SnapView.h; sourceTree = ""; }; 56 | 3686753E320B7F2B2138FDBC /* UIView+Category.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+Category.h"; sourceTree = ""; }; 57 | 368676DE8D250DABA0520C5B /* PushView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = PushView.m; sourceTree = ""; }; 58 | 3686777677F30452D18AC00B /* AdvancedAttachmentView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = AdvancedAttachmentView.m; sourceTree = ""; }; 59 | 368677AFB50647B915E69099 /* SnapView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = SnapView.m; sourceTree = ""; }; 60 | 368677B8ACB8306D4A48C8F9 /* BaseViewWithBall.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BaseViewWithBall.m; sourceTree = ""; }; 61 | 36867B33DBB6BF02774E19E2 /* AdvancedAttachmentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AdvancedAttachmentView.h; sourceTree = ""; }; 62 | 36867B35E773912E92684883 /* UIView+Category.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+Category.m"; sourceTree = ""; }; 63 | 36867B4262C15CCD89BF5349 /* CollisionView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CollisionView.m; sourceTree = ""; }; 64 | 36867C3485AF735A3908C6A9 /* AttachmentView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AttachmentView.h; sourceTree = ""; }; 65 | 36867CA4A747D03A620ED60D /* PushView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PushView.h; sourceTree = ""; }; 66 | 36867D45EBFDA080F4EF81B7 /* BallView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = BallView.m; sourceTree = ""; }; 67 | 36867E0FD884AB598F05B55C /* GeneralViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneralViewController.h; sourceTree = ""; }; 68 | 36867E395943025C40C01040 /* BallView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BallView.h; sourceTree = ""; }; 69 | 36867E83A6D2325CEE84E199 /* GeneralViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneralViewController.m; sourceTree = ""; }; 70 | 49C3E9CF182C3870002D8841 /* UIDynamicExample.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = UIDynamicExample.app; sourceTree = BUILT_PRODUCTS_DIR; }; 71 | 49C3E9D2182C3870002D8841 /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = System/Library/Frameworks/Foundation.framework; sourceTree = SDKROOT; }; 72 | 49C3E9D4182C3870002D8841 /* CoreGraphics.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreGraphics.framework; path = System/Library/Frameworks/CoreGraphics.framework; sourceTree = SDKROOT; }; 73 | 49C3E9D6182C3870002D8841 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; 74 | 49C3E9DA182C3870002D8841 /* UIDynamicExample-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UIDynamicExample-Info.plist"; sourceTree = ""; }; 75 | 49C3E9DC182C3870002D8841 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 76 | 49C3E9DE182C3870002D8841 /* main.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = main.m; sourceTree = ""; }; 77 | 49C3E9E0182C3870002D8841 /* UIDynamicExample-Prefix.pch */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "UIDynamicExample-Prefix.pch"; sourceTree = ""; }; 78 | 49C3E9E1182C3870002D8841 /* AppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = AppDelegate.h; sourceTree = ""; }; 79 | 49C3E9E2182C3870002D8841 /* AppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = AppDelegate.m; sourceTree = ""; }; 80 | 49C3E9E4182C3870002D8841 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; }; 81 | 49C3E9EA182C3870002D8841 /* UIDynamicExampleTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = UIDynamicExampleTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; 82 | 49C3E9EB182C3870002D8841 /* XCTest.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = XCTest.framework; path = Library/Frameworks/XCTest.framework; sourceTree = DEVELOPER_DIR; }; 83 | 49C3E9F3182C3870002D8841 /* UIDynamicExampleTests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "UIDynamicExampleTests-Info.plist"; sourceTree = ""; }; 84 | 49C3E9F5182C3870002D8841 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = ""; }; 85 | 49C3E9F7182C3870002D8841 /* UIDynamicExampleTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = UIDynamicExampleTests.m; sourceTree = ""; }; 86 | /* End PBXFileReference section */ 87 | 88 | /* Begin PBXFrameworksBuildPhase section */ 89 | 49C3E9CC182C3870002D8841 /* Frameworks */ = { 90 | isa = PBXFrameworksBuildPhase; 91 | buildActionMask = 2147483647; 92 | files = ( 93 | 49C3E9D5182C3870002D8841 /* CoreGraphics.framework in Frameworks */, 94 | 49C3E9D7182C3870002D8841 /* UIKit.framework in Frameworks */, 95 | 49C3E9D3182C3870002D8841 /* Foundation.framework in Frameworks */, 96 | ); 97 | runOnlyForDeploymentPostprocessing = 0; 98 | }; 99 | 49C3E9E7182C3870002D8841 /* Frameworks */ = { 100 | isa = PBXFrameworksBuildPhase; 101 | buildActionMask = 2147483647; 102 | files = ( 103 | 49C3E9EC182C3870002D8841 /* XCTest.framework in Frameworks */, 104 | 49C3E9EE182C3870002D8841 /* UIKit.framework in Frameworks */, 105 | 49C3E9ED182C3870002D8841 /* Foundation.framework in Frameworks */, 106 | ); 107 | runOnlyForDeploymentPostprocessing = 0; 108 | }; 109 | /* End PBXFrameworksBuildPhase section */ 110 | 111 | /* Begin PBXGroup section */ 112 | 3686760C54320CFEC30B51EC /* Views */ = { 113 | isa = PBXGroup; 114 | children = ( 115 | 36867320683C7687BA6B208F /* GravityView.m */, 116 | 368673E18CE48D8F215866EF /* GravityView.h */, 117 | 36867D45EBFDA080F4EF81B7 /* BallView.m */, 118 | 36867E395943025C40C01040 /* BallView.h */, 119 | 36867B4262C15CCD89BF5349 /* CollisionView.m */, 120 | 3686742482EACF6B0AFCD013 /* CollisionView.h */, 121 | 368677B8ACB8306D4A48C8F9 /* BaseViewWithBall.m */, 122 | 3686701A253292024D2B34B0 /* BaseViewWithBall.h */, 123 | 368671F44B8F18A61F0BD490 /* AttachmentView.m */, 124 | 36867C3485AF735A3908C6A9 /* AttachmentView.h */, 125 | 3686777677F30452D18AC00B /* AdvancedAttachmentView.m */, 126 | 36867B33DBB6BF02774E19E2 /* AdvancedAttachmentView.h */, 127 | 368677AFB50647B915E69099 /* SnapView.m */, 128 | 368674C3276016F775A49EB5 /* SnapView.h */, 129 | 368676DE8D250DABA0520C5B /* PushView.m */, 130 | 36867CA4A747D03A620ED60D /* PushView.h */, 131 | 36867B35E773912E92684883 /* UIView+Category.m */, 132 | 3686753E320B7F2B2138FDBC /* UIView+Category.h */, 133 | ); 134 | path = Views; 135 | sourceTree = ""; 136 | }; 137 | 36867A4F6D6D00F660D17072 /* ViewControllers */ = { 138 | isa = PBXGroup; 139 | children = ( 140 | 36867E83A6D2325CEE84E199 /* GeneralViewController.m */, 141 | 36867E0FD884AB598F05B55C /* GeneralViewController.h */, 142 | ); 143 | path = ViewControllers; 144 | sourceTree = ""; 145 | }; 146 | 49C3E9C6182C3870002D8841 = { 147 | isa = PBXGroup; 148 | children = ( 149 | 49C3E9D8182C3870002D8841 /* UIDynamicExample */, 150 | 49C3E9F1182C3870002D8841 /* UIDynamicExampleTests */, 151 | 49C3E9D1182C3870002D8841 /* Frameworks */, 152 | 49C3E9D0182C3870002D8841 /* Products */, 153 | ); 154 | sourceTree = ""; 155 | }; 156 | 49C3E9D0182C3870002D8841 /* Products */ = { 157 | isa = PBXGroup; 158 | children = ( 159 | 49C3E9CF182C3870002D8841 /* UIDynamicExample.app */, 160 | 49C3E9EA182C3870002D8841 /* UIDynamicExampleTests.xctest */, 161 | ); 162 | name = Products; 163 | sourceTree = ""; 164 | }; 165 | 49C3E9D1182C3870002D8841 /* Frameworks */ = { 166 | isa = PBXGroup; 167 | children = ( 168 | 49C3E9D2182C3870002D8841 /* Foundation.framework */, 169 | 49C3E9D4182C3870002D8841 /* CoreGraphics.framework */, 170 | 49C3E9D6182C3870002D8841 /* UIKit.framework */, 171 | 49C3E9EB182C3870002D8841 /* XCTest.framework */, 172 | ); 173 | name = Frameworks; 174 | sourceTree = ""; 175 | }; 176 | 49C3E9D8182C3870002D8841 /* UIDynamicExample */ = { 177 | isa = PBXGroup; 178 | children = ( 179 | 49C3E9E1182C3870002D8841 /* AppDelegate.h */, 180 | 49C3E9E2182C3870002D8841 /* AppDelegate.m */, 181 | 49C3E9E4182C3870002D8841 /* Images.xcassets */, 182 | 49C3E9D9182C3870002D8841 /* Supporting Files */, 183 | 368671A593EC171709730665 /* MainViewController.m */, 184 | 36867196D14AE983965C51FC /* MainViewController.h */, 185 | 36867A4F6D6D00F660D17072 /* ViewControllers */, 186 | 3686760C54320CFEC30B51EC /* Views */, 187 | 36867277A3CBA5B51467245A /* bang.png */, 188 | ); 189 | path = UIDynamicExample; 190 | sourceTree = ""; 191 | }; 192 | 49C3E9D9182C3870002D8841 /* Supporting Files */ = { 193 | isa = PBXGroup; 194 | children = ( 195 | 49C3E9DA182C3870002D8841 /* UIDynamicExample-Info.plist */, 196 | 49C3E9DB182C3870002D8841 /* InfoPlist.strings */, 197 | 49C3E9DE182C3870002D8841 /* main.m */, 198 | 49C3E9E0182C3870002D8841 /* UIDynamicExample-Prefix.pch */, 199 | ); 200 | name = "Supporting Files"; 201 | sourceTree = ""; 202 | }; 203 | 49C3E9F1182C3870002D8841 /* UIDynamicExampleTests */ = { 204 | isa = PBXGroup; 205 | children = ( 206 | 49C3E9F7182C3870002D8841 /* UIDynamicExampleTests.m */, 207 | 49C3E9F2182C3870002D8841 /* Supporting Files */, 208 | ); 209 | path = UIDynamicExampleTests; 210 | sourceTree = ""; 211 | }; 212 | 49C3E9F2182C3870002D8841 /* Supporting Files */ = { 213 | isa = PBXGroup; 214 | children = ( 215 | 49C3E9F3182C3870002D8841 /* UIDynamicExampleTests-Info.plist */, 216 | 49C3E9F4182C3870002D8841 /* InfoPlist.strings */, 217 | ); 218 | name = "Supporting Files"; 219 | sourceTree = ""; 220 | }; 221 | /* End PBXGroup section */ 222 | 223 | /* Begin PBXNativeTarget section */ 224 | 49C3E9CE182C3870002D8841 /* UIDynamicExample */ = { 225 | isa = PBXNativeTarget; 226 | buildConfigurationList = 49C3E9FB182C3870002D8841 /* Build configuration list for PBXNativeTarget "UIDynamicExample" */; 227 | buildPhases = ( 228 | 49C3E9CB182C3870002D8841 /* Sources */, 229 | 49C3E9CC182C3870002D8841 /* Frameworks */, 230 | 49C3E9CD182C3870002D8841 /* Resources */, 231 | ); 232 | buildRules = ( 233 | ); 234 | dependencies = ( 235 | ); 236 | name = UIDynamicExample; 237 | productName = UIDynamicExample; 238 | productReference = 49C3E9CF182C3870002D8841 /* UIDynamicExample.app */; 239 | productType = "com.apple.product-type.application"; 240 | }; 241 | 49C3E9E9182C3870002D8841 /* UIDynamicExampleTests */ = { 242 | isa = PBXNativeTarget; 243 | buildConfigurationList = 49C3E9FE182C3870002D8841 /* Build configuration list for PBXNativeTarget "UIDynamicExampleTests" */; 244 | buildPhases = ( 245 | 49C3E9E6182C3870002D8841 /* Sources */, 246 | 49C3E9E7182C3870002D8841 /* Frameworks */, 247 | 49C3E9E8182C3870002D8841 /* Resources */, 248 | ); 249 | buildRules = ( 250 | ); 251 | dependencies = ( 252 | 49C3E9F0182C3870002D8841 /* PBXTargetDependency */, 253 | ); 254 | name = UIDynamicExampleTests; 255 | productName = UIDynamicExampleTests; 256 | productReference = 49C3E9EA182C3870002D8841 /* UIDynamicExampleTests.xctest */; 257 | productType = "com.apple.product-type.bundle.unit-test"; 258 | }; 259 | /* End PBXNativeTarget section */ 260 | 261 | /* Begin PBXProject section */ 262 | 49C3E9C7182C3870002D8841 /* Project object */ = { 263 | isa = PBXProject; 264 | attributes = { 265 | LastUpgradeCheck = 0500; 266 | TargetAttributes = { 267 | 49C3E9E9182C3870002D8841 = { 268 | TestTargetID = 49C3E9CE182C3870002D8841 /* UIDynamicExample */; 269 | }; 270 | }; 271 | }; 272 | buildConfigurationList = 49C3E9CA182C3870002D8841 /* Build configuration list for PBXProject "UIDynamicExample" */; 273 | compatibilityVersion = "Xcode 3.2"; 274 | developmentRegion = English; 275 | hasScannedForEncodings = 0; 276 | knownRegions = ( 277 | en, 278 | ); 279 | mainGroup = 49C3E9C6182C3870002D8841; 280 | productRefGroup = 49C3E9D0182C3870002D8841 /* Products */; 281 | projectDirPath = ""; 282 | projectRoot = ""; 283 | targets = ( 284 | 49C3E9CE182C3870002D8841 /* UIDynamicExample */, 285 | 49C3E9E9182C3870002D8841 /* UIDynamicExampleTests */, 286 | ); 287 | }; 288 | /* End PBXProject section */ 289 | 290 | /* Begin PBXResourcesBuildPhase section */ 291 | 49C3E9CD182C3870002D8841 /* Resources */ = { 292 | isa = PBXResourcesBuildPhase; 293 | buildActionMask = 2147483647; 294 | files = ( 295 | 49C3E9DD182C3870002D8841 /* InfoPlist.strings in Resources */, 296 | 49C3E9E5182C3870002D8841 /* Images.xcassets in Resources */, 297 | 368670CA0C009F0D1F059C7F /* bang.png in Resources */, 298 | ); 299 | runOnlyForDeploymentPostprocessing = 0; 300 | }; 301 | 49C3E9E8182C3870002D8841 /* Resources */ = { 302 | isa = PBXResourcesBuildPhase; 303 | buildActionMask = 2147483647; 304 | files = ( 305 | 49C3E9F6182C3870002D8841 /* InfoPlist.strings in Resources */, 306 | ); 307 | runOnlyForDeploymentPostprocessing = 0; 308 | }; 309 | /* End PBXResourcesBuildPhase section */ 310 | 311 | /* Begin PBXSourcesBuildPhase section */ 312 | 49C3E9CB182C3870002D8841 /* Sources */ = { 313 | isa = PBXSourcesBuildPhase; 314 | buildActionMask = 2147483647; 315 | files = ( 316 | 49C3E9E3182C3870002D8841 /* AppDelegate.m in Sources */, 317 | 49C3E9DF182C3870002D8841 /* main.m in Sources */, 318 | 3686775E1916DCD6540F2499 /* MainViewController.m in Sources */, 319 | 368675E8F0104D18D8B3C91F /* GravityView.m in Sources */, 320 | 3686759D50AAFEBEA0786997 /* BallView.m in Sources */, 321 | 36867BF87EEA7BF2A94FC3DD /* CollisionView.m in Sources */, 322 | 36867476A5A2229142E0D25A /* BaseViewWithBall.m in Sources */, 323 | 36867B128C249E5B2ECC54A0 /* AttachmentView.m in Sources */, 324 | 36867FAF75CAC11275429C03 /* GeneralViewController.m in Sources */, 325 | 368674F1613E5B8466D7DEA9 /* AdvancedAttachmentView.m in Sources */, 326 | 36867F489959D69986906F7A /* SnapView.m in Sources */, 327 | 3686795E2E8F3BD26C14BD34 /* PushView.m in Sources */, 328 | 368677F7E5305344700D83B3 /* UIView+Category.m in Sources */, 329 | ); 330 | runOnlyForDeploymentPostprocessing = 0; 331 | }; 332 | 49C3E9E6182C3870002D8841 /* Sources */ = { 333 | isa = PBXSourcesBuildPhase; 334 | buildActionMask = 2147483647; 335 | files = ( 336 | 49C3E9F8182C3870002D8841 /* UIDynamicExampleTests.m in Sources */, 337 | ); 338 | runOnlyForDeploymentPostprocessing = 0; 339 | }; 340 | /* End PBXSourcesBuildPhase section */ 341 | 342 | /* Begin PBXTargetDependency section */ 343 | 49C3E9F0182C3870002D8841 /* PBXTargetDependency */ = { 344 | isa = PBXTargetDependency; 345 | target = 49C3E9CE182C3870002D8841 /* UIDynamicExample */; 346 | targetProxy = 49C3E9EF182C3870002D8841 /* PBXContainerItemProxy */; 347 | }; 348 | /* End PBXTargetDependency section */ 349 | 350 | /* Begin PBXVariantGroup section */ 351 | 49C3E9DB182C3870002D8841 /* InfoPlist.strings */ = { 352 | isa = PBXVariantGroup; 353 | children = ( 354 | 49C3E9DC182C3870002D8841 /* en */, 355 | ); 356 | name = InfoPlist.strings; 357 | sourceTree = ""; 358 | }; 359 | 49C3E9F4182C3870002D8841 /* InfoPlist.strings */ = { 360 | isa = PBXVariantGroup; 361 | children = ( 362 | 49C3E9F5182C3870002D8841 /* en */, 363 | ); 364 | name = InfoPlist.strings; 365 | sourceTree = ""; 366 | }; 367 | /* End PBXVariantGroup section */ 368 | 369 | /* Begin XCBuildConfiguration section */ 370 | 49C3E9F9182C3870002D8841 /* Debug */ = { 371 | isa = XCBuildConfiguration; 372 | buildSettings = { 373 | ALWAYS_SEARCH_USER_PATHS = NO; 374 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 375 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 376 | CLANG_CXX_LIBRARY = "libc++"; 377 | CLANG_ENABLE_MODULES = YES; 378 | CLANG_ENABLE_OBJC_ARC = YES; 379 | CLANG_WARN_BOOL_CONVERSION = YES; 380 | CLANG_WARN_CONSTANT_CONVERSION = YES; 381 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 382 | CLANG_WARN_EMPTY_BODY = YES; 383 | CLANG_WARN_ENUM_CONVERSION = YES; 384 | CLANG_WARN_INT_CONVERSION = YES; 385 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 386 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 387 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 388 | COPY_PHASE_STRIP = NO; 389 | GCC_C_LANGUAGE_STANDARD = gnu99; 390 | GCC_DYNAMIC_NO_PIC = NO; 391 | GCC_OPTIMIZATION_LEVEL = 0; 392 | GCC_PREPROCESSOR_DEFINITIONS = ( 393 | "DEBUG=1", 394 | "$(inherited)", 395 | ); 396 | GCC_SYMBOLS_PRIVATE_EXTERN = NO; 397 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 398 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 399 | GCC_WARN_UNDECLARED_SELECTOR = YES; 400 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 401 | GCC_WARN_UNUSED_FUNCTION = YES; 402 | GCC_WARN_UNUSED_VARIABLE = YES; 403 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 404 | ONLY_ACTIVE_ARCH = YES; 405 | SDKROOT = iphoneos; 406 | }; 407 | name = Debug; 408 | }; 409 | 49C3E9FA182C3870002D8841 /* Release */ = { 410 | isa = XCBuildConfiguration; 411 | buildSettings = { 412 | ALWAYS_SEARCH_USER_PATHS = NO; 413 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 414 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; 415 | CLANG_CXX_LIBRARY = "libc++"; 416 | CLANG_ENABLE_MODULES = YES; 417 | CLANG_ENABLE_OBJC_ARC = YES; 418 | CLANG_WARN_BOOL_CONVERSION = YES; 419 | CLANG_WARN_CONSTANT_CONVERSION = YES; 420 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; 421 | CLANG_WARN_EMPTY_BODY = YES; 422 | CLANG_WARN_ENUM_CONVERSION = YES; 423 | CLANG_WARN_INT_CONVERSION = YES; 424 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; 425 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; 426 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; 427 | COPY_PHASE_STRIP = YES; 428 | ENABLE_NS_ASSERTIONS = NO; 429 | GCC_C_LANGUAGE_STANDARD = gnu99; 430 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES; 431 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; 432 | GCC_WARN_UNDECLARED_SELECTOR = YES; 433 | GCC_WARN_UNINITIALIZED_AUTOS = YES; 434 | GCC_WARN_UNUSED_FUNCTION = YES; 435 | GCC_WARN_UNUSED_VARIABLE = YES; 436 | IPHONEOS_DEPLOYMENT_TARGET = 7.0; 437 | SDKROOT = iphoneos; 438 | VALIDATE_PRODUCT = YES; 439 | }; 440 | name = Release; 441 | }; 442 | 49C3E9FC182C3870002D8841 /* Debug */ = { 443 | isa = XCBuildConfiguration; 444 | buildSettings = { 445 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 446 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 447 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 448 | GCC_PREFIX_HEADER = "UIDynamicExample/UIDynamicExample-Prefix.pch"; 449 | INFOPLIST_FILE = "UIDynamicExample/UIDynamicExample-Info.plist"; 450 | PRODUCT_NAME = "$(TARGET_NAME)"; 451 | WRAPPER_EXTENSION = app; 452 | }; 453 | name = Debug; 454 | }; 455 | 49C3E9FD182C3870002D8841 /* Release */ = { 456 | isa = XCBuildConfiguration; 457 | buildSettings = { 458 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; 459 | ASSETCATALOG_COMPILER_LAUNCHIMAGE_NAME = LaunchImage; 460 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 461 | GCC_PREFIX_HEADER = "UIDynamicExample/UIDynamicExample-Prefix.pch"; 462 | INFOPLIST_FILE = "UIDynamicExample/UIDynamicExample-Info.plist"; 463 | PRODUCT_NAME = "$(TARGET_NAME)"; 464 | WRAPPER_EXTENSION = app; 465 | }; 466 | name = Release; 467 | }; 468 | 49C3E9FF182C3870002D8841 /* Debug */ = { 469 | isa = XCBuildConfiguration; 470 | buildSettings = { 471 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 472 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/UIDynamicExample.app/UIDynamicExample"; 473 | FRAMEWORK_SEARCH_PATHS = ( 474 | "$(SDKROOT)/Developer/Library/Frameworks", 475 | "$(inherited)", 476 | "$(DEVELOPER_FRAMEWORKS_DIR)", 477 | ); 478 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 479 | GCC_PREFIX_HEADER = "UIDynamicExample/UIDynamicExample-Prefix.pch"; 480 | GCC_PREPROCESSOR_DEFINITIONS = ( 481 | "DEBUG=1", 482 | "$(inherited)", 483 | ); 484 | INFOPLIST_FILE = "UIDynamicExampleTests/UIDynamicExampleTests-Info.plist"; 485 | PRODUCT_NAME = "$(TARGET_NAME)"; 486 | TEST_HOST = "$(BUNDLE_LOADER)"; 487 | WRAPPER_EXTENSION = xctest; 488 | }; 489 | name = Debug; 490 | }; 491 | 49C3EA00182C3870002D8841 /* Release */ = { 492 | isa = XCBuildConfiguration; 493 | buildSettings = { 494 | ARCHS = "$(ARCHS_STANDARD_INCLUDING_64_BIT)"; 495 | BUNDLE_LOADER = "$(BUILT_PRODUCTS_DIR)/UIDynamicExample.app/UIDynamicExample"; 496 | FRAMEWORK_SEARCH_PATHS = ( 497 | "$(SDKROOT)/Developer/Library/Frameworks", 498 | "$(inherited)", 499 | "$(DEVELOPER_FRAMEWORKS_DIR)", 500 | ); 501 | GCC_PRECOMPILE_PREFIX_HEADER = YES; 502 | GCC_PREFIX_HEADER = "UIDynamicExample/UIDynamicExample-Prefix.pch"; 503 | INFOPLIST_FILE = "UIDynamicExampleTests/UIDynamicExampleTests-Info.plist"; 504 | PRODUCT_NAME = "$(TARGET_NAME)"; 505 | TEST_HOST = "$(BUNDLE_LOADER)"; 506 | WRAPPER_EXTENSION = xctest; 507 | }; 508 | name = Release; 509 | }; 510 | /* End XCBuildConfiguration section */ 511 | 512 | /* Begin XCConfigurationList section */ 513 | 49C3E9CA182C3870002D8841 /* Build configuration list for PBXProject "UIDynamicExample" */ = { 514 | isa = XCConfigurationList; 515 | buildConfigurations = ( 516 | 49C3E9F9182C3870002D8841 /* Debug */, 517 | 49C3E9FA182C3870002D8841 /* Release */, 518 | ); 519 | defaultConfigurationIsVisible = 0; 520 | defaultConfigurationName = Release; 521 | }; 522 | 49C3E9FB182C3870002D8841 /* Build configuration list for PBXNativeTarget "UIDynamicExample" */ = { 523 | isa = XCConfigurationList; 524 | buildConfigurations = ( 525 | 49C3E9FC182C3870002D8841 /* Debug */, 526 | 49C3E9FD182C3870002D8841 /* Release */, 527 | ); 528 | defaultConfigurationIsVisible = 0; 529 | }; 530 | 49C3E9FE182C3870002D8841 /* Build configuration list for PBXNativeTarget "UIDynamicExampleTests" */ = { 531 | isa = XCConfigurationList; 532 | buildConfigurations = ( 533 | 49C3E9FF182C3870002D8841 /* Debug */, 534 | 49C3EA00182C3870002D8841 /* Release */, 535 | ); 536 | defaultConfigurationIsVisible = 0; 537 | }; 538 | /* End XCConfigurationList section */ 539 | }; 540 | rootObject = 49C3E9C7182C3870002D8841 /* Project object */; 541 | } 542 | -------------------------------------------------------------------------------- /UIDynamicExample.xcodeproj/project.xcworkspace/contents.xcworkspacedata: -------------------------------------------------------------------------------- 1 | 2 | 4 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /UIDynamicExample/AppDelegate.h: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.h 3 | // UIDynamicExample 4 | // 5 | // Created by jli on 11/8/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface AppDelegate : UIResponder 12 | 13 | @property (strong, nonatomic) UIWindow *window; 14 | 15 | @end 16 | -------------------------------------------------------------------------------- /UIDynamicExample/AppDelegate.m: -------------------------------------------------------------------------------- 1 | // 2 | // AppDelegate.m 3 | // UIDynamicExample 4 | // 5 | // Created by jli on 11/8/13. 6 | // 7 | // 8 | 9 | #import "AppDelegate.h" 10 | #import "MainViewController.h" 11 | 12 | @implementation AppDelegate 13 | 14 | - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 15 | { 16 | self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; 17 | // Override point for customization after application launch. 18 | 19 | MainViewController *mainViewController = [[MainViewController alloc] init]; 20 | UINavigationController *navigationController = [[UINavigationController alloc] initWithRootViewController:mainViewController]; 21 | self.window.backgroundColor = [UIColor whiteColor]; 22 | self.window.rootViewController = navigationController; 23 | [self.window makeKeyAndVisible]; 24 | return YES; 25 | } 26 | 27 | - (void)applicationWillResignActive:(UIApplication *)application 28 | { 29 | // 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. 30 | // 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. 31 | } 32 | 33 | - (void)applicationDidEnterBackground:(UIApplication *)application 34 | { 35 | // 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. 36 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. 37 | } 38 | 39 | - (void)applicationWillEnterForeground:(UIApplication *)application 40 | { 41 | // 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. 42 | } 43 | 44 | - (void)applicationDidBecomeActive:(UIApplication *)application 45 | { 46 | // 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. 47 | } 48 | 49 | - (void)applicationWillTerminate:(UIApplication *)application 50 | { 51 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. 52 | } 53 | 54 | @end 55 | -------------------------------------------------------------------------------- /UIDynamicExample/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 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /UIDynamicExample/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 | "info" : { 20 | "version" : 1, 21 | "author" : "xcode" 22 | } 23 | } -------------------------------------------------------------------------------- /UIDynamicExample/MainViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface MainViewController : UITableViewController 4 | @end -------------------------------------------------------------------------------- /UIDynamicExample/MainViewController.m: -------------------------------------------------------------------------------- 1 | #import "MainViewController.h" 2 | #import "GeneralViewController.h" 3 | 4 | #define keyItemName @"name" 5 | #define keyClassName @"class" 6 | 7 | @implementation MainViewController { 8 | NSArray *items; 9 | } 10 | 11 | - (id)init { 12 | self = [super init]; 13 | if (self) { 14 | items = [self setupItems]; 15 | [self.navigationItem setTitle:@"Dynamic Behaviours"]; 16 | } 17 | return self; 18 | } 19 | 20 | 21 | - (NSArray *)setupItems { 22 | return @[@{keyItemName : @"Gravity", keyClassName : @"GravityView"}, 23 | @{keyItemName : @"Collision", keyClassName : @"CollisionView"}, 24 | @{keyItemName : @"Attachment", keyClassName : @"AttachmentView"}, 25 | @{keyItemName : @"Advanced Attachment", keyClassName : @"AdvancedAttachmentView"}, 26 | @{keyItemName : @"Snap", keyClassName : @"SnapView"}, 27 | @{keyItemName : @"Push", keyClassName : @"PushView"}]; 28 | } 29 | 30 | - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 31 | UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"]; 32 | if (!cell) { 33 | cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"]; 34 | } 35 | [cell.textLabel setText:items[[indexPath row]][keyItemName]]; 36 | cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; 37 | return cell; 38 | } 39 | 40 | - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 41 | return [items count]; 42 | } 43 | 44 | - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 45 | NSDictionary *item = items[[indexPath row]]; 46 | GeneralViewController *viewController = [[GeneralViewController alloc] initWithViewName:item[keyClassName] andTitle:item[keyItemName]]; 47 | [[self navigationController] pushViewController:viewController animated:NO]; 48 | } 49 | 50 | @end -------------------------------------------------------------------------------- /UIDynamicExample/UIDynamicExample-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleDisplayName 8 | ${PRODUCT_NAME} 9 | CFBundleExecutable 10 | ${EXECUTABLE_NAME} 11 | CFBundleIdentifier 12 | xiaodao.${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 | 38 | 39 | -------------------------------------------------------------------------------- /UIDynamicExample/UIDynamicExample-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_3_0 10 | #warning "This project uses features only available in iOS SDK 3.0 and later." 11 | #endif 12 | 13 | #ifdef __OBJC__ 14 | 15 | #import 16 | #import 17 | #import "UIView+Category.h" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /UIDynamicExample/ViewControllers/GeneralViewController.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface GeneralViewController : UIViewController 4 | - (id)initWithViewName:(NSString *)aViewName andTitle:(NSString *)title; 5 | @end -------------------------------------------------------------------------------- /UIDynamicExample/ViewControllers/GeneralViewController.m: -------------------------------------------------------------------------------- 1 | #import "GeneralViewController.h" 2 | 3 | @implementation GeneralViewController { 4 | NSString *viewName; 5 | } 6 | - (id)initWithViewName:(NSString *)aViewName andTitle: (NSString *) title{ 7 | self = [super init]; 8 | if (self) { 9 | viewName = aViewName; 10 | [self.navigationItem setTitle:title]; 11 | 12 | } 13 | return self; 14 | } 15 | 16 | - (void)loadView { 17 | self.view = [[NSClassFromString(viewName) alloc]init]; 18 | } 19 | 20 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/AdvancedAttachmentView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface AdvancedAttachmentView : UIView 4 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/AdvancedAttachmentView.m: -------------------------------------------------------------------------------- 1 | #import "AdvancedAttachmentView.h" 2 | #import "BallView.h" 3 | 4 | @implementation AdvancedAttachmentView { 5 | UIDynamicAnimator *animator; 6 | UIAttachmentBehavior *dragBehaviour; 7 | NSMutableArray *ballViews; 8 | UIPanGestureRecognizer *panGestureRecognizer; 9 | } 10 | - (id)init { 11 | self = [super init]; 12 | if (self) { 13 | [self buildBall]; 14 | [self setupAnimatorAndGestureRecognizer]; 15 | [self addBehaviour]; 16 | } 17 | 18 | return self; 19 | } 20 | 21 | - (void)setupAnimatorAndGestureRecognizer { 22 | animator = [[UIDynamicAnimator alloc] initWithReferenceView:self]; 23 | panGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handleAttachmentGesture:)]; 24 | } 25 | 26 | - (void)buildBall { 27 | ballViews = [[NSMutableArray alloc] init]; 28 | for (NSUInteger i = 0; i < 4; i++) { 29 | UIView *view = [[BallView alloc] init]; 30 | view.center = CGPointMake(80 + i * 50, 400); 31 | [self addSubview:view]; 32 | ballViews[i] = view; 33 | } 34 | } 35 | 36 | - (void)addBehaviour { 37 | for (NSUInteger i = 0; i < [ballViews count] - 1; i++) { 38 | UIAttachmentBehavior *attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:ballViews[i] attachedToItem:ballViews[i + 1]]; 39 | [animator addBehavior:attachmentBehavior]; 40 | } 41 | [self addGestureRecognizer:panGestureRecognizer]; 42 | } 43 | 44 | - (void)handleAttachmentGesture:(UIPanGestureRecognizer *)gestureRecognizer { 45 | if (gestureRecognizer.state == UIGestureRecognizerStateBegan) { 46 | [self initDragBehaviourWithAnchorPosition:[gestureRecognizer locationInView:self]]; 47 | [animator addBehavior:dragBehaviour]; 48 | } else if (gestureRecognizer.state == UIGestureRecognizerStateChanged) { 49 | [dragBehaviour setAnchorPoint:[gestureRecognizer locationInView:self]]; 50 | } else if (gestureRecognizer.state == UIGestureRecognizerStateEnded) { 51 | [animator removeAllBehaviors]; 52 | [self removeGestureRecognizer:panGestureRecognizer]; 53 | [self addGravityAfterDragEnded]; 54 | } 55 | } 56 | 57 | - (void)addGravityAfterDragEnded { 58 | UIGravityBehavior *gravityBehavior = [[UIGravityBehavior alloc] initWithItems:ballViews]; 59 | [animator addBehavior:gravityBehavior]; 60 | 61 | UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc] initWithItems:ballViews]; 62 | [collisionBehavior setTranslatesReferenceBoundsIntoBoundary:YES]; 63 | [animator addBehavior:collisionBehavior]; 64 | } 65 | 66 | - (void)initDragBehaviourWithAnchorPosition:(CGPoint)anchorPosition { 67 | UIView *ballView = ballViews[0]; 68 | dragBehaviour = [[UIAttachmentBehavior alloc] initWithItem:ballView attachedToAnchor:anchorPosition]; 69 | double length = [self getDistanceBetweenAnchor:anchorPosition andBallView:ballView]; 70 | [dragBehaviour setLength:((CGFloat) length < 20) ? (CGFloat) length : 20]; 71 | } 72 | 73 | - (double)getDistanceBetweenAnchor:(CGPoint)anchor andBallView:(UIView *)ballView { 74 | return sqrt(pow((anchor.x - ballView.center.x), 2.0) + pow((anchor.y - ballView.center.y), 2.0)); 75 | } 76 | 77 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/AttachmentView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "BaseViewWithBall.h" 3 | 4 | @interface AttachmentView : BaseViewWithBall 5 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/AttachmentView.m: -------------------------------------------------------------------------------- 1 | #import "AttachmentView.h" 2 | 3 | @implementation AttachmentView 4 | 5 | - (id)init { 6 | self = [super init]; 7 | if (self) { 8 | [self addGravity]; 9 | } 10 | return self; 11 | } 12 | 13 | - (void)addGravity { 14 | theAnimator = [[UIDynamicAnimator alloc] initWithReferenceView:self]; 15 | UIGravityBehavior *gravityBehaviour = [[UIGravityBehavior alloc] initWithItems:@[ballView]]; 16 | [theAnimator addBehavior:gravityBehaviour]; 17 | 18 | UIAttachmentBehavior *attachmentBehavior = [[UIAttachmentBehavior alloc] initWithItem:ballView attachedToAnchor:CGPointMake(100, 0)]; 19 | [attachmentBehavior setLength:300]; 20 | [attachmentBehavior setDamping:0.1]; 21 | [attachmentBehavior setFrequency:5]; 22 | [theAnimator addBehavior:attachmentBehavior]; 23 | 24 | } 25 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/BallView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BallView : UIView 4 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/BallView.m: -------------------------------------------------------------------------------- 1 | #import "BallView.h" 2 | 3 | @implementation BallView { 4 | 5 | } 6 | 7 | - (id)init { 8 | self = [super init]; 9 | if (self) { 10 | [self setFrame:CGRectMake(0, 0, 40, 40)]; 11 | self.backgroundColor = [UIColor lightGrayColor]; 12 | self.layer.cornerRadius = 20; 13 | self.layer.borderColor = [UIColor grayColor].CGColor; 14 | self.layer.borderWidth = 2; 15 | } 16 | return self; 17 | } 18 | 19 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/BaseViewWithBall.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface BaseViewWithBall : UIView{ 4 | UIView *ballView; 5 | UIDynamicAnimator *theAnimator; 6 | } 7 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/BaseViewWithBall.m: -------------------------------------------------------------------------------- 1 | #import "BaseViewWithBall.h" 2 | #import "BallView.h" 3 | 4 | @implementation BaseViewWithBall { 5 | 6 | } 7 | 8 | - (id)init { 9 | self = [super init]; 10 | if (self) { 11 | [self buildBall]; 12 | } 13 | return self; 14 | } 15 | 16 | 17 | - (void)buildBall { 18 | ballView = [[BallView alloc] init]; 19 | ballView.center = CGPointMake(100, 100); 20 | [self addSubview:ballView]; 21 | } 22 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/CollisionView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "BaseViewWithBall.h" 3 | 4 | @interface CollisionView : BaseViewWithBall 5 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/CollisionView.m: -------------------------------------------------------------------------------- 1 | #import "CollisionView.h" 2 | 3 | @implementation CollisionView { 4 | UIImageView *_imageView; 5 | } 6 | 7 | - (id)init { 8 | self = [super init]; 9 | if (self) { 10 | [self addDynamicBehaviour]; 11 | [self createBangImage]; 12 | } 13 | return self; 14 | } 15 | 16 | - (void)addDynamicBehaviour { 17 | theAnimator = [[UIDynamicAnimator alloc] initWithReferenceView:self]; 18 | UIGravityBehavior *gravityBehavior = [[UIGravityBehavior alloc] initWithItems:@[ballView]]; 19 | [theAnimator addBehavior:gravityBehavior]; 20 | 21 | UICollisionBehavior *collisionBehavior = [[UICollisionBehavior alloc] initWithItems:@[ballView]]; 22 | [collisionBehavior setTranslatesReferenceBoundsIntoBoundary:YES]; 23 | [theAnimator addBehavior:collisionBehavior]; 24 | 25 | UIDynamicItemBehavior *itemBehavior = [[UIDynamicItemBehavior alloc] initWithItems:@[ballView]]; 26 | [itemBehavior setElasticity:0.6]; 27 | [theAnimator addBehavior:itemBehavior]; 28 | [collisionBehavior setCollisionDelegate:self]; 29 | } 30 | 31 | - (void)createBangImage { 32 | _imageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"bang.png"]]; 33 | [_imageView setFrame:CGRectMake(100, [UIScreen mainScreen].bounds.size.height - 100, 40, 40)]; 34 | [_imageView.layer setHidden:YES]; 35 | [self addSubview:_imageView]; 36 | } 37 | 38 | - (void)collisionBehavior:(UICollisionBehavior *)behavior 39 | endedContactForItem:(id )item 40 | withBoundaryIdentifier:(id )identifier { 41 | [self bang]; 42 | } 43 | 44 | - (void)bang { 45 | CABasicAnimation *animation = [CABasicAnimation animationWithKeyPath:@"hidden"]; 46 | [animation setToValue:[NSNumber numberWithBool:NO]]; 47 | [animation setDuration:0.2]; 48 | [animation setRemovedOnCompletion:YES]; 49 | [_imageView.layer addAnimation:animation forKey:nil]; 50 | } 51 | 52 | 53 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/GravityView.h: -------------------------------------------------------------------------------- 1 | #import 2 | #import "BaseViewWithBall.h" 3 | 4 | @interface GravityView : BaseViewWithBall 5 | 6 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/GravityView.m: -------------------------------------------------------------------------------- 1 | #import "GravityView.h" 2 | 3 | @implementation GravityView { 4 | } 5 | 6 | - (id)init { 7 | self = [super init]; 8 | if (self) { 9 | [self addGravity]; 10 | } 11 | return self; 12 | } 13 | 14 | - (void)addGravity { 15 | theAnimator = [[UIDynamicAnimator alloc] initWithReferenceView:self]; 16 | UIGravityBehavior *gravityBehaviour = [[UIGravityBehavior alloc] initWithItems:@[ballView]]; 17 | [theAnimator addBehavior:gravityBehaviour]; 18 | } 19 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/PushView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface PushView : UIView 4 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/PushView.m: -------------------------------------------------------------------------------- 1 | #import "PushView.h" 2 | 3 | @implementation PushView { 4 | UIView *barView; 5 | UIDynamicAnimator *theAnimator; 6 | } 7 | - (id)init { 8 | self = [super init]; 9 | if (self) { 10 | [self addBar]; 11 | theAnimator = [[UIDynamicAnimator alloc] initWithReferenceView:self]; 12 | } 13 | 14 | return self; 15 | } 16 | 17 | - (void)addBar { 18 | barView = [[UIView alloc] initWithFrame:CGRectMake(140, 200, 10, 100)]; 19 | [barView setBackgroundColor:[UIColor lightGrayColor]]; 20 | [self addSubview:barView]; 21 | 22 | UIPanGestureRecognizer *recognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(handlePanGesture:)]; 23 | [self addGestureRecognizer:recognizer]; 24 | } 25 | 26 | - (void)handlePanGesture:(UIPanGestureRecognizer *)gestureRecognizer { 27 | if (gestureRecognizer.state == UIGestureRecognizerStateEnded) { 28 | if ([self gestureHitsBarView:gestureRecognizer]) { 29 | UIPushBehavior *pushBehavior = [[UIPushBehavior alloc] initWithItems:@[barView] mode:UIPushBehaviorModeInstantaneous]; 30 | [pushBehavior setPushDirection:CGVectorMake([gestureRecognizer velocityInView:self].x /5000.f, 0)]; 31 | [theAnimator addBehavior:pushBehavior]; 32 | } 33 | } 34 | } 35 | 36 | - (BOOL)gestureHitsBarView:(UIPanGestureRecognizer *)gestureRecognizer { 37 | CGPoint locationInView = [gestureRecognizer locationInView:self]; 38 | return barView.left <= locationInView.x && locationInView.y <= barView.top + barView.height; 39 | } 40 | 41 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/SnapView.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface SnapView : UIView 4 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/SnapView.m: -------------------------------------------------------------------------------- 1 | #import "SnapView.h" 2 | #import "BallView.h" 3 | 4 | @implementation SnapView { 5 | float radius; 6 | float circleCenterX; 7 | float circleCenterY; 8 | UIDynamicAnimator *theAnimator; 9 | int count; 10 | int ballNumber; 11 | UIButton *dropBallButton; 12 | } 13 | 14 | - (id)init { 15 | self = [super init]; 16 | if (self) { 17 | radius = 40; 18 | circleCenterX = 120; 19 | circleCenterY = 200; 20 | theAnimator = [[UIDynamicAnimator alloc] initWithReferenceView:self]; 21 | [self addCircle]; 22 | [self addButton]; 23 | } 24 | 25 | return self; 26 | } 27 | 28 | - (void)addCircle { 29 | UIView *circle = [[UIView alloc] initWithFrame:CGRectMake(120, 200, 2 * radius, 2 * radius)]; 30 | circle.backgroundColor = [UIColor blackColor]; 31 | circle.layer.cornerRadius = 40; 32 | [self addSubview:circle]; 33 | } 34 | 35 | - (void)addButton { 36 | dropBallButton = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 37 | [dropBallButton setFrame:CGRectMake(110, 400, 100, 20)]; 38 | [dropBallButton setTitle:@"Drop ball" forState:UIControlStateNormal]; 39 | [dropBallButton addTarget:self action:@selector(dropBall) forControlEvents:UIControlEventTouchDown]; 40 | [self addSubview:dropBallButton]; 41 | } 42 | 43 | - (void)dropBall { 44 | [self resetStatus]; 45 | UIView *ballView = [self addBallView]; 46 | [self addDynamicBehaviour:ballView]; 47 | ballNumber++; 48 | } 49 | 50 | - (void)addDynamicBehaviour:(UIView *)ballView { 51 | UIGravityBehavior *gravityBehaviour = [[UIGravityBehavior alloc] initWithItems:@[ballView]]; 52 | [gravityBehaviour setAction:^{ 53 | count++; 54 | if (count == 50) { 55 | UISnapBehavior *snapBehavior = [[UISnapBehavior alloc] initWithItem:ballView 56 | snapToPoint:CGPointMake([self getPositionXFor:ballNumber * M_PI / 3], [self getPositionYFor:ballNumber * M_PI / 3])]; 57 | [theAnimator addBehavior:snapBehavior]; 58 | [dropBallButton setEnabled:ballNumber != 6]; 59 | } 60 | }]; 61 | [theAnimator addBehavior:gravityBehaviour]; 62 | } 63 | 64 | - (void)resetStatus { 65 | count = 0; 66 | [theAnimator removeAllBehaviors]; 67 | [dropBallButton setEnabled:NO]; 68 | } 69 | 70 | - (double)getPositionYFor:(double)radian { 71 | return circleCenterY + radius + radius * sin(radian); 72 | } 73 | 74 | - (double)getPositionXFor:(double)radian { 75 | return circleCenterX + radius + radius * cos(radian); 76 | } 77 | 78 | - (UIView *)addBallView { 79 | UIView *ballView = [[BallView alloc] init]; 80 | ballView.center = CGPointMake(50, 100); 81 | [self addSubview:ballView]; 82 | return ballView; 83 | } 84 | 85 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/UIView+Category.h: -------------------------------------------------------------------------------- 1 | #import 2 | 3 | @interface UIView (Category) 4 | - (CGFloat)left; 5 | 6 | - (CGFloat)top; 7 | 8 | - (CGFloat)width; 9 | 10 | - (CGFloat)height; 11 | 12 | - (CGPoint)origin; 13 | @end -------------------------------------------------------------------------------- /UIDynamicExample/Views/UIView+Category.m: -------------------------------------------------------------------------------- 1 | #import "UIView+Category.h" 2 | 3 | @implementation UIView (Category) 4 | 5 | - (CGFloat)left { 6 | return [self frame].origin.x; 7 | } 8 | 9 | - (CGFloat)top { 10 | return [self frame].origin.y; 11 | } 12 | 13 | - (CGFloat)width { 14 | return [self frame].size.width; 15 | } 16 | 17 | - (CGFloat)height { 18 | return [self frame].size.height; 19 | } 20 | 21 | - (CGPoint)origin { 22 | return [self frame].origin; 23 | } 24 | 25 | @end 26 | 27 | -------------------------------------------------------------------------------- /UIDynamicExample/bang.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangfenxiaodao/UIDynamicExample/09f5313f6e4ab6f1ddb399eb78817fc86e14c023/UIDynamicExample/bang.png -------------------------------------------------------------------------------- /UIDynamicExample/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /UIDynamicExample/main.m: -------------------------------------------------------------------------------- 1 | // 2 | // main.m 3 | // UIDynamicExample 4 | // 5 | // Created by jli on 11/8/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | #import "AppDelegate.h" 12 | 13 | int main(int argc, char * argv[]) 14 | { 15 | @autoreleasepool { 16 | return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /UIDynamicExampleTests/UIDynamicExampleTests-Info.plist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | CFBundleDevelopmentRegion 6 | en 7 | CFBundleExecutable 8 | ${EXECUTABLE_NAME} 9 | CFBundleIdentifier 10 | xiaodao.${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 | -------------------------------------------------------------------------------- /UIDynamicExampleTests/UIDynamicExampleTests.m: -------------------------------------------------------------------------------- 1 | // 2 | // UIDynamicExampleTests.m 3 | // UIDynamicExampleTests 4 | // 5 | // Created by jli on 11/8/13. 6 | // 7 | // 8 | 9 | #import 10 | 11 | @interface UIDynamicExampleTests : XCTestCase 12 | 13 | @end 14 | 15 | @implementation UIDynamicExampleTests 16 | 17 | - (void)setUp 18 | { 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 | { 25 | // Put teardown code here. This method is called after the invocation of each test method in the class. 26 | [super tearDown]; 27 | } 28 | 29 | - (void)testExample 30 | { 31 | XCTFail(@"No implementation for \"%s\"", __PRETTY_FUNCTION__); 32 | } 33 | 34 | @end 35 | -------------------------------------------------------------------------------- /UIDynamicExampleTests/en.lproj/InfoPlist.strings: -------------------------------------------------------------------------------- 1 | /* Localized versions of Info.plist keys */ 2 | 3 | -------------------------------------------------------------------------------- /snapshots/advanced_attachment.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangfenxiaodao/UIDynamicExample/09f5313f6e4ab6f1ddb399eb78817fc86e14c023/snapshots/advanced_attachment.gif -------------------------------------------------------------------------------- /snapshots/attachment.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangfenxiaodao/UIDynamicExample/09f5313f6e4ab6f1ddb399eb78817fc86e14c023/snapshots/attachment.gif -------------------------------------------------------------------------------- /snapshots/collision.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangfenxiaodao/UIDynamicExample/09f5313f6e4ab6f1ddb399eb78817fc86e14c023/snapshots/collision.gif -------------------------------------------------------------------------------- /snapshots/gravity.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangfenxiaodao/UIDynamicExample/09f5313f6e4ab6f1ddb399eb78817fc86e14c023/snapshots/gravity.gif -------------------------------------------------------------------------------- /snapshots/push.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangfenxiaodao/UIDynamicExample/09f5313f6e4ab6f1ddb399eb78817fc86e14c023/snapshots/push.gif -------------------------------------------------------------------------------- /snapshots/snap.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/liangfenxiaodao/UIDynamicExample/09f5313f6e4ab6f1ddb399eb78817fc86e14c023/snapshots/snap.gif --------------------------------------------------------------------------------