├── Explosion.gif
├── DCExplosion.gif
├── Example (Explodable)
├── Example (Explodable)
│ ├── Assets.xcassets
│ │ ├── Contents.json
│ │ ├── image.imageset
│ │ │ ├── image.png
│ │ │ └── Contents.json
│ │ ├── Background.imageset
│ │ │ ├── astronaut.png
│ │ │ └── Contents.json
│ │ ├── Front.imageset
│ │ │ ├── meteor-dribbble.png
│ │ │ └── Contents.json
│ │ └── AppIcon.appiconset
│ │ │ └── Contents.json
│ ├── ImageViewController.swift
│ ├── Info.plist
│ ├── ViewController.swift
│ ├── UIAnimationGroup+Callback.swift
│ ├── Base.lproj
│ │ ├── LaunchScreen.storyboard
│ │ └── Main.storyboard
│ ├── CellController.swift
│ ├── AppDelegate.swift
│ └── Explodable.swift
└── Example (Explodable).xcodeproj
│ ├── project.xcworkspace
│ └── contents.xcworkspacedata
│ └── project.pbxproj
├── DCExplosion.podspec.json
├── LICENSE
├── .gitignore
├── README.md
└── Source
└── Explodable.swift
/Explosion.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tangdixi/DCExplosion/HEAD/Explosion.gif
--------------------------------------------------------------------------------
/DCExplosion.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tangdixi/DCExplosion/HEAD/DCExplosion.gif
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Assets.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Assets.xcassets/image.imageset/image.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tangdixi/DCExplosion/HEAD/Example (Explodable)/Example (Explodable)/Assets.xcassets/image.imageset/image.png
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Assets.xcassets/Background.imageset/astronaut.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tangdixi/DCExplosion/HEAD/Example (Explodable)/Example (Explodable)/Assets.xcassets/Background.imageset/astronaut.png
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Assets.xcassets/Front.imageset/meteor-dribbble.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Tangdixi/DCExplosion/HEAD/Example (Explodable)/Example (Explodable)/Assets.xcassets/Front.imageset/meteor-dribbble.png
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable).xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Assets.xcassets/image.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "filename" : "image.png",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Assets.xcassets/Background.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "astronaut.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Assets.xcassets/Front.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "filename" : "meteor-dribbble.png",
6 | "scale" : "1x"
7 | },
8 | {
9 | "idiom" : "universal",
10 | "scale" : "2x"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/DCExplosion.podspec.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "DCExplosion",
3 | "version": "1.1",
4 | "summary": "Allow you remove a subview with explode animation",
5 | "homepage": "https://github.com/Tangdixi/DCExplosion",
6 | "license": {
7 | "type": "MIT",
8 | "text": "The DCExplosion use the MIT license"
9 | },
10 | "authors": {
11 | "Tangdixi": "Tangdixi@gmail.com"
12 | },
13 | "platforms": {
14 | "ios": "8.0"
15 | },
16 | "source": {
17 | "git": "https://github.com/Tangdixi/DCExplosion.git",
18 | "tag": "1.1"
19 | },
20 | "source_files": "Source/*.swift",
21 | "requires_arc": true
22 | }
23 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/ImageViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // File.swift
3 | // Example (Explodable)
4 | //
5 | // Created by tang dixi on 22/7/2016.
6 | // Copyright © 2016 Tangdixi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ImageViewController: UIViewController {
12 |
13 | let directions = [ExplodeDirection.top, ExplodeDirection.bottom, ExplodeDirection.left, ExplodeDirection.right, ExplodeDirection.chaos]
14 |
15 | @IBOutlet weak var frontImageView: UIImageView!
16 |
17 | @IBAction func crashTapped(_ sender: AnyObject) {
18 |
19 | let randomDirection = Int(arc4random_uniform(UInt32(4 - 0)) + 0)
20 | let direction = directions[randomDirection]
21 |
22 | frontImageView?.explode(direction, duration: 3) {
23 | guard let navigationController = self.navigationController else { return }
24 |
25 | navigationController.popViewController(animated: true)
26 | }
27 |
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | }
43 | ],
44 | "info" : {
45 | "version" : 1,
46 | "author" : "xcode"
47 | }
48 | }
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016 Tangdixi
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 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | DCExplosion
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 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // Example (Explodable)
4 | //
5 | // Created by tang dixi on 17/6/2016.
6 | // Copyright © 2016 Tangdixi. All rights reserved.
7 | //
8 |
9 | import Foundation
10 | import UIKit
11 |
12 | var directions = [ExplodeDirection.left, ExplodeDirection.top, ExplodeDirection.right, ExplodeDirection.bottom, ExplodeDirection.chaos]
13 |
14 | class ViewController: UIViewController {
15 |
16 | @IBOutlet weak var bottomView: UIView!
17 | var imageView = UIImageView()
18 | var direction = directions.first!
19 | var duration = Double(1)
20 |
21 | override func viewDidLoad() {
22 | if imageView.superview == nil {
23 | imageView.frame = self.bottomView.bounds
24 | imageView.image = UIImage(named: "image")
25 | bottomView.addSubview(imageView)
26 | }
27 | }
28 |
29 | @IBAction func explodeDirectionChanged(_ sender: AnyObject) {
30 | guard let segment = sender as? UISegmentedControl else { return }
31 | direction = directions[segment.selectedSegmentIndex]
32 | }
33 |
34 | @IBAction func explodeDurationChanged(_ sender: AnyObject) {
35 | guard let slider = sender as? UISlider else { return }
36 | duration = Double(slider.value)
37 | }
38 |
39 | @IBAction func explode(_ sender: AnyObject) {
40 | imageView.explode(direction, duration: duration) {
41 | self.bottomView.addSubview(self.imageView)
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/UIAnimationGroup+Callback.swift:
--------------------------------------------------------------------------------
1 | //
2 | // UIAnimationGroup+Block.swift
3 | // Example (Explodable)
4 | //
5 | // Created by tang dixi on 18/6/2016.
6 | // Copyright © 2016 Tangdixi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | typealias CAAnimationGroupCompletion = (()->Void)
12 |
13 | class CAAnimationGroupCompletionWrapper {
14 | var closure:(CAAnimationGroupCompletion)?
15 | init(closure:CAAnimationGroupCompletion?) {
16 | self.closure = closure
17 | }
18 | }
19 |
20 | extension CAAnimationGroup {
21 |
22 | private struct AssociatedKeys {
23 | static var descriptiveName = "CAAnimationGroupClosure"
24 | }
25 | var completion:(()->Void)? {
26 | set {
27 | if let newValue = newValue {
28 | self.delegate = self
29 | objc_setAssociatedObject(
30 | self,
31 | &AssociatedKeys.descriptiveName,
32 | CAAnimationGroupCompletionWrapper(closure: newValue),
33 | .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
34 | }
35 | }
36 | get {
37 | guard let closureWrapper = objc_getAssociatedObject(self, &AssociatedKeys.descriptiveName) as? CAAnimationGroupCompletionWrapper else { return nil }
38 | return closureWrapper.closure
39 | }
40 | }
41 | public override func animationDidStop(anim: CAAnimation, finished flag: Bool) {
42 | if flag == true {
43 |
44 | guard let closureWrapper = objc_getAssociatedObject(self, &AssociatedKeys.descriptiveName) as? CAAnimationGroupCompletionWrapper else { return }
45 | guard let closure = closureWrapper.closure else { return }
46 |
47 | closure()
48 | }
49 | }
50 |
51 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | # gitignore contributors: remember to update Global/Xcode.gitignore, Objective-C.gitignore & Swift.gitignore
4 |
5 | ## Build generated
6 | build/
7 | DerivedData/
8 |
9 | ## Various settings
10 | *.pbxuser
11 | !default.pbxuser
12 | *.mode1v3
13 | !default.mode1v3
14 | *.mode2v3
15 | !default.mode2v3
16 | *.perspectivev3
17 | !default.perspectivev3
18 | xcuserdata/
19 |
20 | ## Other
21 | *.moved-aside
22 | *.xcuserstate
23 |
24 | ## Obj-C/Swift specific
25 | *.hmap
26 | *.ipa
27 | *.dSYM.zip
28 | *.dSYM
29 |
30 | ## Playgrounds
31 | timeline.xctimeline
32 | playground.xcworkspace
33 |
34 | # Swift Package Manager
35 | #
36 | # Add this line if you want to avoid checking in source code from Swift Package Manager dependencies.
37 | # Packages/
38 | .build/
39 |
40 | # CocoaPods
41 | #
42 | # We recommend against adding the Pods directory to your .gitignore. However
43 | # you should judge for yourself, the pros and cons are mentioned at:
44 | # https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
45 | #
46 | # Pods/
47 |
48 | # Carthage
49 | #
50 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
51 | # Carthage/Checkouts
52 |
53 | Carthage/Build
54 |
55 | # fastlane
56 | #
57 | # It is recommended to not store the screenshots in the git repo. Instead, use fastlane to re-generate the
58 | # screenshots whenever they are needed.
59 | # For more information about the recommended setup visit:
60 | # https://github.com/fastlane/fastlane/blob/master/fastlane/docs/Gitignore.md
61 |
62 | fastlane/report.xml
63 | fastlane/Preview.html
64 | fastlane/screenshots
65 | fastlane/test_output
66 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/CellController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // Example (Explodable)
4 | //
5 | // Created by tang dixi on 7/6/2016.
6 | // Copyright © 2016 Tangdixi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | extension UIView:Explodable { }
12 |
13 | var data = ["1", "2", "3", "4", "5"]
14 |
15 | class CellController: UIViewController, Explodable {
16 |
17 | @IBOutlet weak var tableView: UITableView!
18 |
19 | override func viewDidLoad() {
20 | super.viewDidLoad()
21 | // Do any additional setup after loading the view, typically from a nib.
22 | data = ["1", "2", "3", "4", "5"]
23 | }
24 |
25 | @IBAction func refreshTapped(_ sender: AnyObject) {
26 | data = ["1", "2", "3", "4", "5", "6"]
27 | tableView.reloadData()
28 | }
29 |
30 | }
31 |
32 | extension CellController:UITableViewDelegate {
33 |
34 | func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
35 | return UIView()
36 | }
37 |
38 | }
39 |
40 | extension CellController:UITableViewDataSource {
41 |
42 | func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
43 | tableView.explodeRowAtIndexPath(indexPath, duration:1 ,direction: .right) {
44 | data.remove(at: indexPath.row)
45 | }
46 | }
47 |
48 | func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
49 | let cell = tableView.dequeueReusableCell(withIdentifier: "Cell", for: indexPath)
50 | cell.imageView?.image = UIImage(named: "image")
51 | cell.textLabel?.text = data[indexPath.row]
52 | return cell
53 | }
54 |
55 | func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
56 | return data.count
57 | }
58 |
59 | func numberOfSections(in tableView: UITableView) -> Int {
60 | return 1
61 | }
62 |
63 | }
64 |
65 |
66 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # DCExplosion
2 |
3 | 
4 |
5 |
6 |
7 | 
8 |
9 | **DCExplosion** allow you to remove a view with explode animation. Written in Swift, using [Protocol-Oriented Programming](https://developer.apple.com/videos/play/wwdc2015/408/)
10 |
11 | ## How To Get Started
12 | - Download [**DCExplosion**](https://codeload.github.com/Tangdixi/DCExplosion/zip/master)
13 | - Clone **DCExplosion**
14 | ```bash
15 | git clone git@github.com:Tangdixi/DCExplosion.git
16 | ```
17 |
18 | ##Installation
19 |
20 | Drag the **Source** into your project.
21 | Well, it is strongly recommended that you install via [**CocoaPods**](https://cocoapods.org)
22 |
23 | ## Usage
24 | * Conform the protocol
25 | ```swift
26 | extension UIView:Explodable { }
27 | ```
28 | * Explode a view and remove it from superView
29 | ```swift
30 | yourView.explode(duration: 1)
31 | ```
32 | * Explode a view and remove it from superView using the specified direction
33 | ```swift
34 | imageView.explode(.Chaos, duration: 1)
35 | ```
36 | * Explode a view and remove it from superView using the specified direction and completion handler
37 | ```swift
38 | imageView.explode(.Chaos, duration: 1) {
39 | // do something here ...
40 | }
41 | ```
42 | * Explode a TableViewCell and delete it from UITableView using the specified direction and completion handler
43 | ```swift
44 | tableView.explodeRowAtIndexPath(indexPath, duration:1 ,direction: .Chaos) {
45 | dataSource.removeAtIndex(indexPath.row)
46 | }
47 | ```
48 |
49 | ## Documentation
50 | **Xcode Quick Help Documentation Supported**
51 |
52 | ## Bug, Suggestions
53 |
54 | Just open an [issue](https://github.com/Tangdixi/DCExplosion/issues) ~
55 |
56 | ## TODO
57 | * Remove a UICollectionCell with explode animation
58 | * More than explosion style
59 |
60 | ## License
61 |
62 | **DCExplosion** is available under the MIT license. See the LICENSE file for more info.
63 |
64 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // Example (Explodable)
4 | //
5 | // Created by tang dixi on 7/6/2016.
6 | // Copyright © 2016 Tangdixi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | @UIApplicationMain
12 | class AppDelegate: UIResponder, UIApplicationDelegate {
13 |
14 | var window: UIWindow?
15 |
16 |
17 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
18 | // Override point for customization after application launch.
19 | return true
20 | }
21 |
22 | func applicationWillResignActive(_ application: UIApplication) {
23 | // 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.
24 | // 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.
25 | }
26 |
27 | func applicationDidEnterBackground(_ application: UIApplication) {
28 | // 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.
29 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
30 | }
31 |
32 | func applicationWillEnterForeground(_ application: UIApplication) {
33 | // 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.
34 | }
35 |
36 | func applicationDidBecomeActive(_ application: UIApplication) {
37 | // 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.
38 | }
39 |
40 | func applicationWillTerminate(_ application: UIApplication) {
41 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
42 | }
43 |
44 |
45 | }
46 |
47 |
--------------------------------------------------------------------------------
/Source/Explodable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Explodable.swift
3 | // Example (Explodable)
4 | //
5 | // Created by tang dixi on 7/6/2016.
6 | // Copyright © 2016 Tangdixi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | protocol Explodable {}
12 |
13 | /**
14 | The explode direction of the animation
15 | - Top: The fragment will explode upward
16 | - Left: The fragment will explode leftward
17 | - Right: The fragment will explode rightward
18 | - Bottom: The fragment will explode downward
19 | - Chaos: The fragment will explode randomly
20 | */
21 | enum ExplodeDirection {
22 | case top, left, bottom, right, chaos
23 | fileprivate func explodeDirection(_ offset:CGSize) -> CGVector {
24 | switch self {
25 | case .top:
26 | let xOffset = random(from: -16.8, to: 16.8)
27 | let yOffset = random(from: -offset.height*goldenRatio, to: 0)
28 | return CGVector(dx: xOffset, dy: yOffset)
29 | case .left:
30 | let xOffset = random(from: -offset.width*goldenRatio, to: 0)
31 | let yOffset = random(from: -16.8, to: 16.8)
32 | return CGVector(dx: xOffset, dy: yOffset)
33 | case .bottom:
34 | let xOffset = random(from: -16.8, to: 16.8)
35 | let yOffset = random(from: 0, to: offset.height*goldenRatio)
36 | return CGVector(dx: xOffset, dy: yOffset)
37 | case .right:
38 | let xOffset = random(from: 0, to: offset.width*goldenRatio)
39 | let yOffset = random(from: -16.8, to: 16.8)
40 | return CGVector(dx: xOffset, dy: yOffset)
41 | case .chaos:
42 | let xOffset = random(from: -offset.width*goldenRatio, to: offset.width*goldenRatio)
43 | let yOffset = random(from: -offset.height*goldenRatio, to: offset.height*goldenRatio)
44 | return CGVector(dx: xOffset, dy: yOffset)
45 | }
46 | }
47 | }
48 |
49 | extension Explodable where Self:UIView {
50 |
51 | /**
52 | Explode a view using the specified duration and direction
53 | - Parameter duration: The animation duration
54 | - Parameter direction: The explode direction, default is `ExplodeDirection.Chaos`
55 | */
56 | func explode(_ direction:ExplodeDirection = .chaos, duration:Double) {
57 | explode(direction, duration: duration) {}
58 | }
59 |
60 | /**
61 | Explode a view using the specified duration ,direction and completion handler
62 | - Parameter duration: The total duration of the animation
63 | - Parameter direction: The explode direction, default is `ExplodeDirection.Chaos`
64 | - Parameter completion: A closure to be executed when the animation sequence ends.
65 | */
66 | func explode(_ direction:ExplodeDirection = .chaos, duration:Double, completion:@escaping (()->Void)) {
67 |
68 | guard let containerView = self.superview else { fatalError() }
69 | let fragments = generateFragmentsFrom(self, with: splitRatio, in: containerView)
70 | self.alpha = 0
71 |
72 | UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveEaseOut,
73 | animations: {
74 | fragments.forEach {
75 |
76 | let direction = direction.explodeDirection($0.superview!.frame.size)
77 | let explodeAngle = random(from: -CGFloat(M_PI)*goldenRatio, to: CGFloat(M_PI)*goldenRatio)
78 | let scale = 0.01 + random(from: 0.01, to: goldenRatio)
79 |
80 | let translateTransform = CGAffineTransform(translationX: direction.dx, y: direction.dy)
81 | let angleTransform = translateTransform.rotated(by: explodeAngle)
82 | let scaleTransform = angleTransform.scaledBy(x: scale, y: scale)
83 |
84 | $0.transform = scaleTransform
85 | $0.alpha = 0
86 |
87 | }
88 | },
89 | completion: { _ in
90 | fragments.forEach {
91 | $0.removeFromSuperview()
92 | }
93 | self.removeFromSuperview()
94 | self.alpha = 1
95 | completion()
96 | })
97 | }
98 |
99 | }
100 |
101 | extension Explodable where Self:UITableView {
102 |
103 | /**
104 | Remove a row in tableView with explosion animation
105 | - Parameter indexPath: An indexPath locate a row in _tableView_
106 | - Parameter duration: The total duration of the animation
107 | - Parameter direction: The explode direction, default is _ExplodeDirection.Chaos_
108 | - Parameter completion: A closure to be executed when the animation sqquence ends, also you should update the dataSource here
109 | */
110 | func explodeRowAtIndexPath(_ indexPath:IndexPath, duration:Double, direction:ExplodeDirection = .chaos, completion:@escaping ()->Void) {
111 |
112 | if self.exploding == true {
113 | return
114 | }
115 |
116 | guard let cell = self.cellForRow(at: indexPath) else { return }
117 | if cell.backgroundView == nil {
118 | cell.backgroundView = UIView()
119 | }
120 |
121 | let fragments = generateFragmentsFrom(cell, with: 10, in: cell)
122 | cell.contentView.alpha = 0
123 |
124 | UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveLinear,
125 | animations: {
126 | self.exploding = true
127 | fragments.forEach {
128 |
129 | let direction = direction.explodeDirection($0.superview!.frame.size)
130 | let explodeAngle = random(from: -CGFloat(M_PI)*goldenRatio, to: CGFloat(M_PI)*goldenRatio)
131 | let scale = 0.01 + random(from: 0.01, to: goldenRatio)
132 |
133 | let translateTransform = CGAffineTransform(translationX: direction.dx, y: direction.dy)
134 | let angleTransform = translateTransform.rotated(by: explodeAngle)
135 | let scaleTransform = angleTransform.scaledBy(x: scale, y: scale)
136 |
137 | $0.transform = scaleTransform
138 | $0.alpha = 0
139 |
140 | }
141 | },
142 | completion: { _ in
143 | fragments.forEach {
144 | $0.removeFromSuperview()
145 | }
146 |
147 | completion()
148 |
149 | CATransaction.begin()
150 | CATransaction.setCompletionBlock {
151 | cell.contentView.alpha = 1
152 | }
153 | self.deleteRows(at: [indexPath], with: .none)
154 | CATransaction.commit()
155 |
156 | self.exploding = false
157 | })
158 |
159 | }
160 |
161 | }
162 |
163 | // MARK: - Private Stuff
164 |
165 | /// Add a `explosing` variation to UITableView in runtime
166 | private extension UITableView {
167 |
168 | struct AssociatedKeys {
169 | static var associatedName = "exploding"
170 | }
171 |
172 | var exploding:Bool {
173 | get {
174 | guard let exploding = objc_getAssociatedObject(self, &AssociatedKeys.associatedName) as? Bool else { return false }
175 | return exploding
176 | }
177 | set {
178 | objc_setAssociatedObject(self, &AssociatedKeys.associatedName, newValue as Bool, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
179 | }
180 | }
181 |
182 | }
183 |
184 | private let goldenRatio = CGFloat(0.625)
185 | private let splitRatio = CGFloat(10)
186 |
187 | private func generateFragmentsFrom(_ originView:UIView, with splitRatio:CGFloat, in containerView:UIView) -> [UIView] {
188 |
189 | let size = originView.frame.size
190 | let snapshots = originView.snapshotView(afterScreenUpdates: true)
191 | var fragments = [UIView]()
192 |
193 | let shortSide = min(size.width, size.height)
194 | let gap = max(20, shortSide/splitRatio)
195 |
196 | for x in stride(from: 0.0, to: Double(size.width), by: Double(gap)) {
197 | for y in stride(from: 0.0, to: Double(size.height), by: Double(gap)) {
198 |
199 | let fragmentRect = CGRect(x: CGFloat(x), y: CGFloat(y), width: size.width/splitRatio, height: size.width/splitRatio)
200 | let fragment = snapshots?.resizableSnapshotView(from: fragmentRect, afterScreenUpdates: false, withCapInsets: UIEdgeInsets.zero)
201 |
202 | fragment?.frame = originView.convert(fragmentRect, to: containerView)
203 | containerView.addSubview(fragment!)
204 | fragments.append(fragment!)
205 |
206 | }
207 | }
208 |
209 | return fragments
210 |
211 | }
212 | private func random(from lowerBound:CGFloat, to upperBound:CGFloat) -> CGFloat {
213 | return CGFloat(arc4random_uniform(UInt32(upperBound - lowerBound))) + lowerBound
214 | }
215 |
216 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Explodable.swift:
--------------------------------------------------------------------------------
1 | //
2 | // Explodable.swift
3 | // Example (Explodable)
4 | //
5 | // Created by tang dixi on 7/6/2016.
6 | // Copyright © 2016 Tangdixi. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | protocol Explodable {}
12 |
13 | /**
14 | The explode direction of the animation
15 | - Top: The fragment will explode upward
16 | - Left: The fragment will explode leftward
17 | - Right: The fragment will explode rightward
18 | - Bottom: The fragment will explode downward
19 | - Chaos: The fragment will explode randomly
20 | */
21 | enum ExplodeDirection {
22 | case top, left, bottom, right, chaos
23 | fileprivate func explodeDirection(_ offset:CGSize) -> CGVector {
24 | switch self {
25 | case .top:
26 | let xOffset = random(from: -16.8, to: 16.8)
27 | let yOffset = random(from: -offset.height*goldenRatio, to: 0)
28 | return CGVector(dx: xOffset, dy: yOffset)
29 | case .left:
30 | let xOffset = random(from: -offset.width*goldenRatio, to: 0)
31 | let yOffset = random(from: -16.8, to: 16.8)
32 | return CGVector(dx: xOffset, dy: yOffset)
33 | case .bottom:
34 | let xOffset = random(from: -16.8, to: 16.8)
35 | let yOffset = random(from: 0, to: offset.height*goldenRatio)
36 | return CGVector(dx: xOffset, dy: yOffset)
37 | case .right:
38 | let xOffset = random(from: 0, to: offset.width*goldenRatio)
39 | let yOffset = random(from: -16.8, to: 16.8)
40 | return CGVector(dx: xOffset, dy: yOffset)
41 | case .chaos:
42 | let xOffset = random(from: -offset.width*goldenRatio, to: offset.width*goldenRatio)
43 | let yOffset = random(from: -offset.height*goldenRatio, to: offset.height*goldenRatio)
44 | return CGVector(dx: xOffset, dy: yOffset)
45 | }
46 | }
47 | }
48 |
49 | extension Explodable where Self:UIView {
50 |
51 | /**
52 | Explode a view using the specified duration and direction
53 | - Parameter duration: The animation duration
54 | - Parameter direction: The explode direction, default is `ExplodeDirection.Chaos`
55 | */
56 | func explode(_ direction:ExplodeDirection = .chaos, duration:Double) {
57 | explode(direction, duration: duration) {}
58 | }
59 |
60 | /**
61 | Explode a view using the specified duration ,direction and completion handler
62 | - Parameter duration: The total duration of the animation
63 | - Parameter direction: The explode direction, default is `ExplodeDirection.Chaos`
64 | - Parameter completion: A closure to be executed when the animation sequence ends.
65 | */
66 | func explode(_ direction:ExplodeDirection = .chaos, duration:Double, completion:@escaping (()->Void)) {
67 |
68 | guard let containerView = self.superview else { fatalError() }
69 | let fragments = generateFragmentsFrom(self, with: splitRatio, in: containerView)
70 | self.alpha = 0
71 |
72 | UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveEaseOut,
73 | animations: {
74 | fragments.forEach {
75 |
76 | let direction = direction.explodeDirection($0.superview!.frame.size)
77 | let explodeAngle = random(from: -CGFloat(M_PI)*goldenRatio, to: CGFloat(M_PI)*goldenRatio)
78 | let scale = 0.01 + random(from: 0.01, to: goldenRatio)
79 |
80 | let translateTransform = CGAffineTransform(translationX: direction.dx, y: direction.dy)
81 | let angleTransform = translateTransform.rotated(by: explodeAngle)
82 | let scaleTransform = angleTransform.scaledBy(x: scale, y: scale)
83 |
84 | $0.transform = scaleTransform
85 | $0.alpha = 0
86 |
87 | }
88 | },
89 | completion: { _ in
90 | fragments.forEach {
91 | $0.removeFromSuperview()
92 | }
93 | self.removeFromSuperview()
94 | self.alpha = 1
95 | completion()
96 | })
97 | }
98 |
99 | }
100 |
101 | extension Explodable where Self:UITableView {
102 |
103 | /**
104 | Remove a row in tableView with explosion animation
105 | - Parameter indexPath: An indexPath locate a row in _tableView_
106 | - Parameter duration: The total duration of the animation
107 | - Parameter direction: The explode direction, default is _ExplodeDirection.Chaos_
108 | - Parameter completion: A closure to be executed when the animation sqquence ends, also you should update the dataSource here
109 | */
110 | func explodeRowAtIndexPath(_ indexPath:IndexPath, duration:Double, direction:ExplodeDirection = .chaos, completion:@escaping ()->Void) {
111 |
112 | if self.exploding == true {
113 | return
114 | }
115 |
116 | guard let cell = self.cellForRow(at: indexPath) else { return }
117 | if cell.backgroundView == nil {
118 | cell.backgroundView = UIView()
119 | }
120 |
121 | let fragments = generateFragmentsFrom(cell, with: 10, in: cell)
122 | cell.contentView.alpha = 0
123 |
124 | UIView.animate(withDuration: duration, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 0, options: UIViewAnimationOptions.curveLinear,
125 | animations: {
126 | self.exploding = true
127 | fragments.forEach {
128 |
129 | let direction = direction.explodeDirection($0.superview!.frame.size)
130 | let explodeAngle = random(from: -CGFloat(M_PI)*goldenRatio, to: CGFloat(M_PI)*goldenRatio)
131 | let scale = 0.01 + random(from: 0.01, to: goldenRatio)
132 |
133 | let translateTransform = CGAffineTransform(translationX: direction.dx, y: direction.dy)
134 | let angleTransform = translateTransform.rotated(by: explodeAngle)
135 | let scaleTransform = angleTransform.scaledBy(x: scale, y: scale)
136 |
137 | $0.transform = scaleTransform
138 | $0.alpha = 0
139 |
140 | }
141 | },
142 | completion: { _ in
143 | fragments.forEach {
144 | $0.removeFromSuperview()
145 | }
146 |
147 | completion()
148 |
149 | CATransaction.begin()
150 | CATransaction.setCompletionBlock {
151 | cell.contentView.alpha = 1
152 | }
153 | self.deleteRows(at: [indexPath], with: .none)
154 | CATransaction.commit()
155 |
156 | self.exploding = false
157 | })
158 |
159 | }
160 |
161 | }
162 |
163 | // MARK: - Private Stuff
164 |
165 | /// Add a `explosing` variation to UITableView in runtime
166 | private extension UITableView {
167 |
168 | struct AssociatedKeys {
169 | static var associatedName = "exploding"
170 | }
171 |
172 | var exploding:Bool {
173 | get {
174 | guard let exploding = objc_getAssociatedObject(self, &AssociatedKeys.associatedName) as? Bool else { return false }
175 | return exploding
176 | }
177 | set {
178 | objc_setAssociatedObject(self, &AssociatedKeys.associatedName, newValue as Bool, .OBJC_ASSOCIATION_RETAIN_NONATOMIC)
179 | }
180 | }
181 |
182 | }
183 |
184 | private let goldenRatio = CGFloat(0.625)
185 | private let splitRatio = CGFloat(10)
186 |
187 | private func generateFragmentsFrom(_ originView:UIView, with splitRatio:CGFloat, in containerView:UIView) -> [UIView] {
188 |
189 | let size = originView.frame.size
190 | let snapshots = originView.snapshotView(afterScreenUpdates: true)
191 | var fragments = [UIView]()
192 |
193 | print("Snapshots:\(snapshots) from \(originView)")
194 |
195 | let shortSide = min(size.width, size.height)
196 | let gap = max(20, shortSide/splitRatio)
197 |
198 | for x in stride(from: 0.0, to: Double(size.width), by: Double(gap)) {
199 | for y in stride(from: 0.0, to: Double(size.height), by: Double(gap)) {
200 |
201 | let fragmentRect = CGRect(x: CGFloat(x), y: CGFloat(y), width: size.width/splitRatio, height: size.width/splitRatio)
202 | let fragment = snapshots?.resizableSnapshotView(from: fragmentRect, afterScreenUpdates: false, withCapInsets: UIEdgeInsets.zero)
203 |
204 | fragment?.frame = originView.convert(fragmentRect, to: containerView)
205 | containerView.addSubview(fragment!)
206 | fragments.append(fragment!)
207 |
208 | }
209 | }
210 |
211 | return fragments
212 |
213 | }
214 | private func random(from lowerBound:CGFloat, to upperBound:CGFloat) -> CGFloat {
215 | return CGFloat(arc4random_uniform(UInt32(upperBound - lowerBound))) + lowerBound
216 | }
217 |
218 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable).xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 812E6F831D06C59C00184E2D /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 812E6F821D06C59C00184E2D /* AppDelegate.swift */; };
11 | 812E6F851D06C59C00184E2D /* CellController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 812E6F841D06C59C00184E2D /* CellController.swift */; };
12 | 812E6F881D06C59C00184E2D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 812E6F861D06C59C00184E2D /* Main.storyboard */; };
13 | 812E6F8A1D06C59C00184E2D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 812E6F891D06C59C00184E2D /* Assets.xcassets */; };
14 | 812E6F8D1D06C59C00184E2D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 812E6F8B1D06C59C00184E2D /* LaunchScreen.storyboard */; };
15 | 812E6F951D06C5AD00184E2D /* Explodable.swift in Sources */ = {isa = PBXBuildFile; fileRef = 812E6F941D06C5AD00184E2D /* Explodable.swift */; };
16 | 8157577B1D4159290005B59A /* ImageViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8157577A1D4159290005B59A /* ImageViewController.swift */; };
17 | 8180C7F91D1449F8005BA724 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 8180C7F81D1449F8005BA724 /* ViewController.swift */; };
18 | /* End PBXBuildFile section */
19 |
20 | /* Begin PBXFileReference section */
21 | 812E6F7F1D06C59C00184E2D /* Example (Explodable).app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example (Explodable).app"; sourceTree = BUILT_PRODUCTS_DIR; };
22 | 812E6F821D06C59C00184E2D /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
23 | 812E6F841D06C59C00184E2D /* CellController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CellController.swift; sourceTree = ""; };
24 | 812E6F871D06C59C00184E2D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
25 | 812E6F891D06C59C00184E2D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
26 | 812E6F8C1D06C59C00184E2D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
27 | 812E6F8E1D06C59C00184E2D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
28 | 812E6F941D06C5AD00184E2D /* Explodable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Explodable.swift; sourceTree = ""; };
29 | 8157577A1D4159290005B59A /* ImageViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ImageViewController.swift; sourceTree = ""; };
30 | 8180C7F81D1449F8005BA724 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
31 | /* End PBXFileReference section */
32 |
33 | /* Begin PBXFrameworksBuildPhase section */
34 | 812E6F7C1D06C59C00184E2D /* Frameworks */ = {
35 | isa = PBXFrameworksBuildPhase;
36 | buildActionMask = 2147483647;
37 | files = (
38 | );
39 | runOnlyForDeploymentPostprocessing = 0;
40 | };
41 | /* End PBXFrameworksBuildPhase section */
42 |
43 | /* Begin PBXGroup section */
44 | 812E6F761D06C59C00184E2D = {
45 | isa = PBXGroup;
46 | children = (
47 | 812E6F811D06C59C00184E2D /* Example (Explodable) */,
48 | 812E6F801D06C59C00184E2D /* Products */,
49 | );
50 | sourceTree = "";
51 | };
52 | 812E6F801D06C59C00184E2D /* Products */ = {
53 | isa = PBXGroup;
54 | children = (
55 | 812E6F7F1D06C59C00184E2D /* Example (Explodable).app */,
56 | );
57 | name = Products;
58 | sourceTree = "";
59 | };
60 | 812E6F811D06C59C00184E2D /* Example (Explodable) */ = {
61 | isa = PBXGroup;
62 | children = (
63 | 812E6F821D06C59C00184E2D /* AppDelegate.swift */,
64 | 812E6F841D06C59C00184E2D /* CellController.swift */,
65 | 8180C7F81D1449F8005BA724 /* ViewController.swift */,
66 | 8157577A1D4159290005B59A /* ImageViewController.swift */,
67 | 812E6F941D06C5AD00184E2D /* Explodable.swift */,
68 | 812E6F861D06C59C00184E2D /* Main.storyboard */,
69 | 812E6F891D06C59C00184E2D /* Assets.xcassets */,
70 | 812E6F8B1D06C59C00184E2D /* LaunchScreen.storyboard */,
71 | 812E6F8E1D06C59C00184E2D /* Info.plist */,
72 | );
73 | path = "Example (Explodable)";
74 | sourceTree = "";
75 | };
76 | /* End PBXGroup section */
77 |
78 | /* Begin PBXNativeTarget section */
79 | 812E6F7E1D06C59C00184E2D /* Example (Explodable) */ = {
80 | isa = PBXNativeTarget;
81 | buildConfigurationList = 812E6F911D06C59C00184E2D /* Build configuration list for PBXNativeTarget "Example (Explodable)" */;
82 | buildPhases = (
83 | 812E6F7B1D06C59C00184E2D /* Sources */,
84 | 812E6F7C1D06C59C00184E2D /* Frameworks */,
85 | 812E6F7D1D06C59C00184E2D /* Resources */,
86 | );
87 | buildRules = (
88 | );
89 | dependencies = (
90 | );
91 | name = "Example (Explodable)";
92 | productName = "Example (Explodable)";
93 | productReference = 812E6F7F1D06C59C00184E2D /* Example (Explodable).app */;
94 | productType = "com.apple.product-type.application";
95 | };
96 | /* End PBXNativeTarget section */
97 |
98 | /* Begin PBXProject section */
99 | 812E6F771D06C59C00184E2D /* Project object */ = {
100 | isa = PBXProject;
101 | attributes = {
102 | LastSwiftUpdateCheck = 0730;
103 | LastUpgradeCheck = 0820;
104 | ORGANIZATIONNAME = Tangdixi;
105 | TargetAttributes = {
106 | 812E6F7E1D06C59C00184E2D = {
107 | CreatedOnToolsVersion = 7.3.1;
108 | DevelopmentTeam = 5A88JF7M74;
109 | LastSwiftMigration = 0820;
110 | };
111 | };
112 | };
113 | buildConfigurationList = 812E6F7A1D06C59C00184E2D /* Build configuration list for PBXProject "Example (Explodable)" */;
114 | compatibilityVersion = "Xcode 3.2";
115 | developmentRegion = English;
116 | hasScannedForEncodings = 0;
117 | knownRegions = (
118 | en,
119 | Base,
120 | );
121 | mainGroup = 812E6F761D06C59C00184E2D;
122 | productRefGroup = 812E6F801D06C59C00184E2D /* Products */;
123 | projectDirPath = "";
124 | projectRoot = "";
125 | targets = (
126 | 812E6F7E1D06C59C00184E2D /* Example (Explodable) */,
127 | );
128 | };
129 | /* End PBXProject section */
130 |
131 | /* Begin PBXResourcesBuildPhase section */
132 | 812E6F7D1D06C59C00184E2D /* Resources */ = {
133 | isa = PBXResourcesBuildPhase;
134 | buildActionMask = 2147483647;
135 | files = (
136 | 812E6F8D1D06C59C00184E2D /* LaunchScreen.storyboard in Resources */,
137 | 812E6F8A1D06C59C00184E2D /* Assets.xcassets in Resources */,
138 | 812E6F881D06C59C00184E2D /* Main.storyboard in Resources */,
139 | );
140 | runOnlyForDeploymentPostprocessing = 0;
141 | };
142 | /* End PBXResourcesBuildPhase section */
143 |
144 | /* Begin PBXSourcesBuildPhase section */
145 | 812E6F7B1D06C59C00184E2D /* Sources */ = {
146 | isa = PBXSourcesBuildPhase;
147 | buildActionMask = 2147483647;
148 | files = (
149 | 8157577B1D4159290005B59A /* ImageViewController.swift in Sources */,
150 | 812E6F851D06C59C00184E2D /* CellController.swift in Sources */,
151 | 812E6F951D06C5AD00184E2D /* Explodable.swift in Sources */,
152 | 8180C7F91D1449F8005BA724 /* ViewController.swift in Sources */,
153 | 812E6F831D06C59C00184E2D /* AppDelegate.swift in Sources */,
154 | );
155 | runOnlyForDeploymentPostprocessing = 0;
156 | };
157 | /* End PBXSourcesBuildPhase section */
158 |
159 | /* Begin PBXVariantGroup section */
160 | 812E6F861D06C59C00184E2D /* Main.storyboard */ = {
161 | isa = PBXVariantGroup;
162 | children = (
163 | 812E6F871D06C59C00184E2D /* Base */,
164 | );
165 | name = Main.storyboard;
166 | sourceTree = "";
167 | };
168 | 812E6F8B1D06C59C00184E2D /* LaunchScreen.storyboard */ = {
169 | isa = PBXVariantGroup;
170 | children = (
171 | 812E6F8C1D06C59C00184E2D /* Base */,
172 | );
173 | name = LaunchScreen.storyboard;
174 | sourceTree = "";
175 | };
176 | /* End PBXVariantGroup section */
177 |
178 | /* Begin XCBuildConfiguration section */
179 | 812E6F8F1D06C59C00184E2D /* Debug */ = {
180 | isa = XCBuildConfiguration;
181 | buildSettings = {
182 | ALWAYS_SEARCH_USER_PATHS = NO;
183 | CLANG_ANALYZER_NONNULL = YES;
184 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
185 | CLANG_CXX_LIBRARY = "libc++";
186 | CLANG_ENABLE_MODULES = YES;
187 | CLANG_ENABLE_OBJC_ARC = YES;
188 | CLANG_WARN_BOOL_CONVERSION = YES;
189 | CLANG_WARN_CONSTANT_CONVERSION = YES;
190 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
191 | CLANG_WARN_EMPTY_BODY = YES;
192 | CLANG_WARN_ENUM_CONVERSION = YES;
193 | CLANG_WARN_INFINITE_RECURSION = YES;
194 | CLANG_WARN_INT_CONVERSION = YES;
195 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
196 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
197 | CLANG_WARN_UNREACHABLE_CODE = YES;
198 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
199 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
200 | COPY_PHASE_STRIP = NO;
201 | DEBUG_INFORMATION_FORMAT = dwarf;
202 | ENABLE_STRICT_OBJC_MSGSEND = YES;
203 | ENABLE_TESTABILITY = YES;
204 | GCC_C_LANGUAGE_STANDARD = gnu99;
205 | GCC_DYNAMIC_NO_PIC = NO;
206 | GCC_NO_COMMON_BLOCKS = YES;
207 | GCC_OPTIMIZATION_LEVEL = 0;
208 | GCC_PREPROCESSOR_DEFINITIONS = (
209 | "DEBUG=1",
210 | "$(inherited)",
211 | );
212 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
213 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
214 | GCC_WARN_UNDECLARED_SELECTOR = YES;
215 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
216 | GCC_WARN_UNUSED_FUNCTION = YES;
217 | GCC_WARN_UNUSED_VARIABLE = YES;
218 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
219 | MTL_ENABLE_DEBUG_INFO = YES;
220 | ONLY_ACTIVE_ARCH = YES;
221 | SDKROOT = iphoneos;
222 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
223 | };
224 | name = Debug;
225 | };
226 | 812E6F901D06C59C00184E2D /* Release */ = {
227 | isa = XCBuildConfiguration;
228 | buildSettings = {
229 | ALWAYS_SEARCH_USER_PATHS = NO;
230 | CLANG_ANALYZER_NONNULL = YES;
231 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
232 | CLANG_CXX_LIBRARY = "libc++";
233 | CLANG_ENABLE_MODULES = YES;
234 | CLANG_ENABLE_OBJC_ARC = YES;
235 | CLANG_WARN_BOOL_CONVERSION = YES;
236 | CLANG_WARN_CONSTANT_CONVERSION = YES;
237 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
238 | CLANG_WARN_EMPTY_BODY = YES;
239 | CLANG_WARN_ENUM_CONVERSION = YES;
240 | CLANG_WARN_INFINITE_RECURSION = YES;
241 | CLANG_WARN_INT_CONVERSION = YES;
242 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
243 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
244 | CLANG_WARN_UNREACHABLE_CODE = YES;
245 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
246 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
247 | COPY_PHASE_STRIP = NO;
248 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
249 | ENABLE_NS_ASSERTIONS = NO;
250 | ENABLE_STRICT_OBJC_MSGSEND = YES;
251 | GCC_C_LANGUAGE_STANDARD = gnu99;
252 | GCC_NO_COMMON_BLOCKS = YES;
253 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
254 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
255 | GCC_WARN_UNDECLARED_SELECTOR = YES;
256 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
257 | GCC_WARN_UNUSED_FUNCTION = YES;
258 | GCC_WARN_UNUSED_VARIABLE = YES;
259 | IPHONEOS_DEPLOYMENT_TARGET = 9.3;
260 | MTL_ENABLE_DEBUG_INFO = NO;
261 | SDKROOT = iphoneos;
262 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
263 | VALIDATE_PRODUCT = YES;
264 | };
265 | name = Release;
266 | };
267 | 812E6F921D06C59C00184E2D /* Debug */ = {
268 | isa = XCBuildConfiguration;
269 | buildSettings = {
270 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
271 | CODE_SIGN_IDENTITY = "iPhone Developer";
272 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
273 | DEVELOPMENT_TEAM = 5A88JF7M74;
274 | INFOPLIST_FILE = "Example (Explodable)/Info.plist";
275 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
276 | PRODUCT_BUNDLE_IDENTIFIER = dc.example.Explodable;
277 | PRODUCT_NAME = "$(TARGET_NAME)";
278 | PROVISIONING_PROFILE = "";
279 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
280 | SWIFT_VERSION = 3.0;
281 | };
282 | name = Debug;
283 | };
284 | 812E6F931D06C59C00184E2D /* Release */ = {
285 | isa = XCBuildConfiguration;
286 | buildSettings = {
287 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
288 | CODE_SIGN_IDENTITY = "iPhone Developer";
289 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
290 | DEVELOPMENT_TEAM = 5A88JF7M74;
291 | INFOPLIST_FILE = "Example (Explodable)/Info.plist";
292 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
293 | PRODUCT_BUNDLE_IDENTIFIER = dc.example.Explodable;
294 | PRODUCT_NAME = "$(TARGET_NAME)";
295 | PROVISIONING_PROFILE = "";
296 | SWIFT_VERSION = 3.0;
297 | };
298 | name = Release;
299 | };
300 | /* End XCBuildConfiguration section */
301 |
302 | /* Begin XCConfigurationList section */
303 | 812E6F7A1D06C59C00184E2D /* Build configuration list for PBXProject "Example (Explodable)" */ = {
304 | isa = XCConfigurationList;
305 | buildConfigurations = (
306 | 812E6F8F1D06C59C00184E2D /* Debug */,
307 | 812E6F901D06C59C00184E2D /* Release */,
308 | );
309 | defaultConfigurationIsVisible = 0;
310 | defaultConfigurationName = Release;
311 | };
312 | 812E6F911D06C59C00184E2D /* Build configuration list for PBXNativeTarget "Example (Explodable)" */ = {
313 | isa = XCConfigurationList;
314 | buildConfigurations = (
315 | 812E6F921D06C59C00184E2D /* Debug */,
316 | 812E6F931D06C59C00184E2D /* Release */,
317 | );
318 | defaultConfigurationIsVisible = 0;
319 | defaultConfigurationName = Release;
320 | };
321 | /* End XCConfigurationList section */
322 | };
323 | rootObject = 812E6F771D06C59C00184E2D /* Project object */;
324 | }
325 |
--------------------------------------------------------------------------------
/Example (Explodable)/Example (Explodable)/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
33 |
46 |
59 |
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 |
91 |
92 |
93 |
94 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
126 |
127 |
128 |
129 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
172 |
173 |
174 |
175 |
176 |
177 |
178 |
179 |
180 |
181 |
182 |
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
215 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
228 |
229 |
230 |
231 |
232 |
233 |
234 |
235 |
236 |
237 |
238 |
239 |
240 |
241 |
242 |
243 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
283 |
284 |
285 |
286 |
287 |
288 |
289 |
290 |
291 |
292 |
293 |
294 |
295 |
296 |
297 |
298 |
299 |
300 |
301 |
302 |
303 |
304 |
--------------------------------------------------------------------------------