• Stars
    star
    2,486
  • Rank 17,703 (Top 0.4 %)
  • Language
    Swift
  • License
    MIT License
  • Created over 9 years ago
  • Updated almost 4 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Play BreakOut while loading - A playable pull to refresh view using SpriteKit

BreakOutToRefresh

Play BreakOut while loading - A playable pull to refresh view using SpriteKit

BreakOutToRefresh uses SpriteKit to add a playable mini game to the pull to refresh view in a table view. In this case the mini game is BreakOut but a lot of other mini games could be presented in this space.

Book

If you like this repository and like'd to give me something back, I wrote a book about funny location based projects for iOS. Please check it out: Build Location-Based Projects for iOS

Installation

CocoaPods

Add this to your Podfile:

use_frameworks!

pod 'BreakOutToRefresh'

Manual

Add BreakOutToRefreshView.swift to your project.

Usage

If you need it only once in your app, add this to your table view controller:

class DemoTableViewController: UITableViewController {

  var refreshView: BreakOutToRefreshView!
  
  // ...
  
  override func viewDidLoad() {
    super.viewDidLoad()
    
    refreshView = BreakOutToRefreshView(scrollView: tableView)
    refreshView.refreshDelegate = self
  
    // configure the refresh view
    refreshView.scenebackgroundColor = .white
    refreshView.textColor = .black
    refreshView.paddleColor = .brown
    refreshView.ballColor = .darkGray
    refreshView.blockColors = [.blue, .green, .red]
  
    tableView.addSubview(refreshView)
  }  
}

extension DemoTableViewController: UIScrollViewDelegate {
 
  override func scrollViewDidScroll(scrollView: UIScrollView) {
    refreshView.scrollViewDidScroll(scrollView)
  }
  
  override func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) {
    refreshView.scrollViewWillEndDragging(scrollView, withVelocity: velocity, targetContentOffset: targetContentOffset)
  }
  
  override func scrollViewWillBeginDragging(scrollView: UIScrollView) {
    refreshView.scrollViewWillBeginDragging(scrollView)
  }
}

extension DemoTableViewController: BreakOutToRefreshDelegate {
  
  func refreshViewDidRefresh(refreshView: BreakOutToRefreshView) {
    // load stuff from the internet
  }

}

In case you need it more than once in your app, add the setup to viewWillAppear and clean up in viewWillDisappear like this:

override func viewWillAppear(_ animated: Bool) {
  super.viewWillAppear(animated)
  
  refreshView = BreakOutToRefreshView(scrollView: tableView)
  refreshView.refreshDelegate = self
  
  // configure the refresh view
  refreshView.scenebackgroundColor = .white
  refreshView.textColor = .black
  refreshView.paddleColor = .brown
  refreshView.ballColor = .darkGray
  refreshView.blockColors = [.blue, .green, .red]
  
  tableView.addSubview(refreshView)
}

override func viewWillDisappear(_ animated: Bool) {
  super.viewWillDisappear(animated)
  
  refreshView.removeFromSuperview()
  refreshView = nil
}

When the loading of new content is finished, call endRefreshing() of the refreshView.

When endRefreshing() is called the mini game doesn't stop immediately. The game stops (and the view is dismissed) when the user lifts the finger. If you like to end the mini game immediately set the forceEnd property to true.

Status

It's kind of beta status.

Feedback

If you use this code or got inspired by the idea and build an app with an even more awesome PullToRefresh game, please let me know.

Author

Dominik Hauser

Twitter: @dasdom

dasdom.github.io

Support

If you want to give me something back, I would highly appreciate if you buy my book about Test-Driven Development with Swift and give me feedback about it.

Thanks

Thanks to Ben Oztalay and raywenderlich.com for inspiration.

Licence

MIT

More Repositories

1

Tomate

This is in the App Store as Fojusi
Swift
533
star
2

UIStackViewPlayground

Playground to play with UIStackViews.
Swift
326
star
3

DDHDynamicViewControllerTransitions

Custom view controller transitions using UIDynamic behaviors.
Objective-C
249
star
4

DDHTimerControl

A control to input minutes or seconds.
Objective-C
209
star
5

SwiftUIExperiments

Experiments with SwiftUI
Swift
117
star
6

DDHCustomTransition

Helper classes to make basic view controller transitions easier
Swift
114
star
7

Storyboard2CodeApp

Mac app that converts an iOS storyboard into code. Work in progress.
Swift
76
star
8

SlideControl

Horizontal slide control build with Swift 2.0
Swift
64
star
9

TableViewMarch2016

Swift
54
star
10

InteractivePlayground

Exploring interactivity in Playgrounds in Xcode 7.3
Swift
54
star
11

CreateAppStoreBill

A perl script and tex files to create bills for the German tax office from Apple's financial reports.
Perl
52
star
12

DDHTextView

A UITextView subclass which let's you move the cursor with a pan gesture.
Objective-C
42
star
13

DDHTweaks

Tweak UI elements at run time to find the perfect values
Swift
27
star
14

DHURLSessionStub

A stub for block based data tasks of NSURLSession.
Shell
23
star
15

Jupp

App with share extension for ADN
Swift
17
star
16

GPXRouteCreator

Swift
14
star
17

EncodeExperiments

Swift
13
star
18

KeychainDemo

Demo project to show how to share a keychain between an App and it's extension
Swift
13
star
19

phazel

Makefile
11
star
20

GravitationFun

Zen in gravity
Swift
11
star
21

BeenOutsideApp

Swift
11
star
22

AutoLayoutInCodeDemo

Swift
10
star
23

ThreeDMill_Messages

https://itunes.apple.com/de/app/3d-mill/id1317617167?l=en&mt=8
Swift
9
star
24

StarWarsTransition

Slide transition for UINavigationController seen in Star Wars films
Swift
9
star
25

SwiftTools

Xcode extension for Swift code
Swift
9
star
26

GimmeTheCodeTDD

Swift Package with examples of how to tests iOS apps
Swift
8
star
27

TestingAlertExperiment

Swift
7
star
28

hAppy

Warning: This is bad code! This is really bad code!
Objective-C
7
star
29

ResponderChainDemo

Swift
7
star
30

Hexadec

A Mac app to easily convert between hexadecimal and decimal integers.
Swift
6
star
31

TikZDrawer

Swift
6
star
32

Poster

An app for quick posting to ADN
Swift
6
star
33

AnimatedTransitionDemo

Swift
6
star
34

DHTweak

An implementation of Facebook Tweaks in Swift
Swift
6
star
35

Swiftandpainless

Swift
6
star
36

ObjCTools

Xcode Source Editor Extension. Download it for free in the App Store: https://itunes.apple.com/de/app/objc-tools/id1419674885?l=en&mt=12
Objective-C
6
star
37

SelectorSyntaxSugar

#selector() and the responder chain
Swift
4
star
38

PullToBrew

Swift
4
star
39

StackViewExperiments

UIStackView experiments
Swift
3
star
40

GlobalADN

Bare bone of a simple ADN client for iOS in Swift
Swift
3
star
41

FinancialReportsParser

Objective-C
3
star
42

UIView-AutoLayout

Category with syntactic sugar for common Auto Layout problems
Objective-C
3
star
43

DynamicTransition

Swift
3
star
44

W00t

Swift
3
star
45

LogStore_ObjC

Log NSLogs into a file and show the log when the device is shaken.
Objective-C
3
star
46

ImplementingModernCollectionViews

Improvements to the Collection View sample code provided by Apple at WWDC 2020
Swift
3
star
47

ReadOutLoud

An app that lets parents record reading a book and taking pictures of the pages. Children can play back that recording.
Swift
3
star
48

AutoLayoutPlayground

Swift
2
star
49

CoolThingsToDoInAPlayground

Swift
2
star
50

Xcode-Snippets

Test related Xcode snippets
2
star
51

ADNPlayground

Swift
2
star
52

HTTPMockExperiments

An experiment using dependency injection to stub NSURLSession calls.
Swift
2
star
53

IntentionsWithSwift

The Intentions example (https://github.com/dasdom/intentions) rewritten in Swift
Swift
2
star
54

CocoaHeads170419

Folien und Code meiner Präsentation beim CocoaHeads Heidelberg vom 19.04.2017
Objective-C
2
star
55

dasdom.github.io

Ruby
2
star
56

LogStore2

Swift
2
star
57

ADNInfo

A ruby script to get basic info from your posts json file you get from ADN.
Ruby
2
star
58

LinksFromCocoaheadsDESlack

2
star
59

CoronaData

Swift
2
star
60

Phy

Swift
2
star
61

TestingNavigationDemo

Swift
1
star
62

TestSample

Swift
1
star
63

CountDown

Swift
1
star
64

adventOfCode2018

Haskell
1
star
65

SwiftUICoordinator

Swift
1
star
66

Numberoids

Swift
1
star
67

ADeelN_icon

Icon for @dasdom's ADeelN (Share to ADN) extension.
1
star
68

EdgeCaseNames

Names to test your projects against
1
star
69

TableViewFooterDemo

Swift
1
star
70

Macopardy

Swift
1
star
71

Beta.link

An index of curated TestFlight beta builds. 📱 Feel free to raise a PR if you want to promote your app.
Swift
1
star
72

AdventOfCode21

Swift
1
star
73

SizeClassesFont

Swift
1
star
74

LogStore

The login library build in my new book: https://pragprog.com/book/dhios/build-location-based-projects-for-ios
Swift
1
star
75

DateFormatterBucket

A singleton to hold all date formatters with custom date format.
Swift
1
star