Skip to content

Commit 687f3d4

Browse files
committed
example project
1 parent d56f016 commit 687f3d4

File tree

7 files changed

+184
-68
lines changed

7 files changed

+184
-68
lines changed

PullToRefresh.xcodeproj/project.pbxproj

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,8 @@
2222
C7AC6CFC19A894DF007107DF /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7AC6CF619A894DF007107DF /* AppDelegate.swift */; };
2323
C7AC6CFD19A894DF007107DF /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = C7AC6CF719A894DF007107DF /* Main.storyboard */; };
2424
C7AC6CFE19A894DF007107DF /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = C7AC6CF919A894DF007107DF /* Images.xcassets */; };
25-
C7AC6D0019A894DF007107DF /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7AC6CFB19A894DF007107DF /* ViewController.swift */; };
25+
C7AC6D0019A894DF007107DF /* PullToRefreshViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7AC6CFB19A894DF007107DF /* PullToRefreshViewController.swift */; };
26+
C7AEDC171B6D53D100E09098 /* ChooseModeViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7AEDC161B6D53D100E09098 /* ChooseModeViewController.swift */; };
2627
C7B53A431AC996B80021914B /* CustomSubview.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7B53A421AC996B80021914B /* CustomSubview.swift */; };
2728
C7B53A451AC9971C0021914B /* CustomSubview.xib in Resources */ = {isa = PBXBuildFile; fileRef = C7B53A441AC9971C0021914B /* CustomSubview.xib */; };
2829
C7DA91CD19B31B7C00C4012B /* Animator.swift in Sources */ = {isa = PBXBuildFile; fileRef = C7DA91CC19B31B7C00C4012B /* Animator.swift */; };
@@ -84,7 +85,8 @@
8485
C7AC6CF819A894DF007107DF /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = "<group>"; };
8586
C7AC6CF919A894DF007107DF /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = "<group>"; };
8687
C7AC6CFA19A894DF007107DF /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
87-
C7AC6CFB19A894DF007107DF /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = "<group>"; };
88+
C7AC6CFB19A894DF007107DF /* PullToRefreshViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PullToRefreshViewController.swift; sourceTree = "<group>"; };
89+
C7AEDC161B6D53D100E09098 /* ChooseModeViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChooseModeViewController.swift; sourceTree = "<group>"; };
8890
C7B53A421AC996B80021914B /* CustomSubview.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CustomSubview.swift; sourceTree = "<group>"; };
8991
C7B53A441AC9971C0021914B /* CustomSubview.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = CustomSubview.xib; sourceTree = "<group>"; };
9092
C7D1CF8F199BB3C8009FD485 /* PullToRefreshDemo.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = PullToRefreshDemo.app; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -168,16 +170,33 @@
168170
isa = PBXGroup;
169171
children = (
170172
C7AC6CF619A894DF007107DF /* AppDelegate.swift */,
171-
C7AC6CFB19A894DF007107DF /* ViewController.swift */,
173+
C7AEDC181B6D53DA00E09098 /* ViewController */,
172174
C7AC6CF719A894DF007107DF /* Main.storyboard */,
173175
C7AC6CF919A894DF007107DF /* Images.xcassets */,
174176
C7956A3D19A8966400CF6484 /* Supporting Files */,
177+
C7AEDC191B6D53E000E09098 /* Animator */,
178+
);
179+
path = PullToRefreshDemo;
180+
sourceTree = "<group>";
181+
};
182+
C7AEDC181B6D53DA00E09098 /* ViewController */ = {
183+
isa = PBXGroup;
184+
children = (
185+
C7AC6CFB19A894DF007107DF /* PullToRefreshViewController.swift */,
186+
C7AEDC161B6D53D100E09098 /* ChooseModeViewController.swift */,
187+
);
188+
name = ViewController;
189+
sourceTree = "<group>";
190+
};
191+
C7AEDC191B6D53E000E09098 /* Animator */ = {
192+
isa = PBXGroup;
193+
children = (
175194
C7A355A119B612D5000DDC72 /* BeatAnimator.swift */,
176195
C7A355D019B62125000DDC72 /* PacmanAnimator.swift */,
177196
C7B53A421AC996B80021914B /* CustomSubview.swift */,
178197
C7B53A441AC9971C0021914B /* CustomSubview.xib */,
179198
);
180-
path = PullToRefreshDemo;
199+
name = Animator;
181200
sourceTree = "<group>";
182201
};
183202
C7D1CF86199BB3C8009FD485 = {
@@ -368,8 +387,9 @@
368387
files = (
369388
C7A355D119B62125000DDC72 /* PacmanAnimator.swift in Sources */,
370389
C7B53A431AC996B80021914B /* CustomSubview.swift in Sources */,
371-
C7AC6D0019A894DF007107DF /* ViewController.swift in Sources */,
390+
C7AC6D0019A894DF007107DF /* PullToRefreshViewController.swift in Sources */,
372391
C7AC6CFC19A894DF007107DF /* AppDelegate.swift in Sources */,
392+
C7AEDC171B6D53D100E09098 /* ChooseModeViewController.swift in Sources */,
373393
C7A355A219B612D5000DDC72 /* BeatAnimator.swift in Sources */,
374394
);
375395
runOnlyForDeploymentPostprocessing = 0;

PullToRefreshDemo/Base.lproj/Main.storyboard

Lines changed: 73 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14D136" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="RWb-co-Zty">
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="7706" systemVersion="14E46" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" initialViewController="RWb-co-Zty">
33
<dependencies>
44
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="7703"/>
55
</dependencies>
@@ -14,27 +14,94 @@
1414
<color key="barTintColor" red="0.96862751245498657" green="0.96862751245498657" blue="0.96862751245498657" alpha="1" colorSpace="deviceRGB"/>
1515
</navigationBar>
1616
<connections>
17-
<segue destination="BYZ-38-t0r" kind="relationship" relationship="rootViewController" id="UhW-aa-ZwF"/>
17+
<segue destination="RFH-zq-9gR" kind="relationship" relationship="rootViewController" id="WGV-CK-QNn"/>
1818
</connections>
1919
</navigationController>
2020
<placeholder placeholderIdentifier="IBFirstResponder" id="Vwd-RL-BVZ" userLabel="First Responder" sceneMemberID="firstResponder"/>
2121
</objects>
2222
<point key="canvasLocation" x="-655" y="59"/>
2323
</scene>
24+
<!--Choose Mode View Controller-->
25+
<scene sceneID="oAy-Hl-ycD">
26+
<objects>
27+
<viewController id="RFH-zq-9gR" customClass="ChooseModeViewController" customModule="PullToRefreshDemo" customModuleProvider="target" sceneMemberID="viewController">
28+
<layoutGuides>
29+
<viewControllerLayoutGuide type="top" id="Jwa-dH-WnZ"/>
30+
<viewControllerLayoutGuide type="bottom" id="WkW-1z-Uxh"/>
31+
</layoutGuides>
32+
<view key="view" contentMode="scaleToFill" id="SeT-4b-Nhw">
33+
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
34+
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
35+
<subviews>
36+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="8ef-eQ-bwJ">
37+
<rect key="frame" x="144" y="96" width="32" height="30"/>
38+
<state key="normal" title="Beat">
39+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
40+
</state>
41+
<connections>
42+
<action selector="beatAction:" destination="RFH-zq-9gR" eventType="touchUpInside" id="j1e-Ug-Hw7"/>
43+
</connections>
44+
</button>
45+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Phb-fN-T5w">
46+
<rect key="frame" x="132" y="134" width="56" height="30"/>
47+
<state key="normal" title="Pacman">
48+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
49+
</state>
50+
<connections>
51+
<action selector="pacmanAction:" destination="RFH-zq-9gR" eventType="touchUpInside" id="aK3-Na-Pco"/>
52+
</connections>
53+
</button>
54+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Bnx-XC-RaR">
55+
<rect key="frame" x="133" y="172" width="54" height="30"/>
56+
<state key="normal" title="Custom">
57+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
58+
</state>
59+
<connections>
60+
<action selector="customAction:" destination="RFH-zq-9gR" eventType="touchUpInside" id="LfN-aH-EiW"/>
61+
</connections>
62+
</button>
63+
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="h5G-X9-Qyf">
64+
<rect key="frame" x="136" y="58" width="49" height="30"/>
65+
<state key="normal" title="Default">
66+
<color key="titleShadowColor" white="0.5" alpha="1" colorSpace="calibratedWhite"/>
67+
</state>
68+
<connections>
69+
<action selector="defaultAction:" destination="RFH-zq-9gR" eventType="touchUpInside" id="vuF-tC-pFA"/>
70+
</connections>
71+
</button>
72+
</subviews>
73+
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
74+
<constraints>
75+
<constraint firstAttribute="centerX" secondItem="Phb-fN-T5w" secondAttribute="centerX" id="PCV-Gn-Hr1"/>
76+
<constraint firstAttribute="centerX" secondItem="8ef-eQ-bwJ" secondAttribute="centerX" id="age-3w-nqf"/>
77+
<constraint firstAttribute="centerX" secondItem="Bnx-XC-RaR" secondAttribute="centerX" id="b7p-mx-ov2"/>
78+
<constraint firstItem="8ef-eQ-bwJ" firstAttribute="top" secondItem="h5G-X9-Qyf" secondAttribute="bottom" constant="8" id="d05-jf-IhB"/>
79+
<constraint firstItem="h5G-X9-Qyf" firstAttribute="top" secondItem="Jwa-dH-WnZ" secondAttribute="bottom" constant="58" id="eMs-2s-g1f"/>
80+
<constraint firstItem="Bnx-XC-RaR" firstAttribute="top" secondItem="Phb-fN-T5w" secondAttribute="bottom" constant="8" id="mTB-9E-ci7"/>
81+
<constraint firstItem="Phb-fN-T5w" firstAttribute="top" secondItem="8ef-eQ-bwJ" secondAttribute="bottom" constant="8" id="u0s-Uu-qxY"/>
82+
<constraint firstAttribute="centerX" secondItem="h5G-X9-Qyf" secondAttribute="centerX" id="wpB-gj-h9z"/>
83+
</constraints>
84+
</view>
85+
<navigationItem key="navigationItem" id="o92-TZ-fbq"/>
86+
</viewController>
87+
<placeholder placeholderIdentifier="IBFirstResponder" id="V7h-TM-QaQ" userLabel="First Responder" sceneMemberID="firstResponder"/>
88+
</objects>
89+
<point key="canvasLocation" x="-243" y="59"/>
90+
</scene>
2491
<!--Pull to refresh example-->
2592
<scene sceneID="tne-QT-ifu">
2693
<objects>
27-
<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="PullToRefreshDemo" customModuleProvider="target" sceneMemberID="viewController">
94+
<viewController storyboardIdentifier="PullToRefreshViewController" id="BYZ-38-t0r" customClass="PullToRefreshViewController" customModule="PullToRefreshDemo" customModuleProvider="target" sceneMemberID="viewController">
2895
<layoutGuides>
2996
<viewControllerLayoutGuide type="top" id="Da1-dG-drI"/>
3097
<viewControllerLayoutGuide type="bottom" id="Uca-LH-LIW"/>
3198
</layoutGuides>
3299
<view key="view" contentMode="scaleToFill" id="8bC-Xf-vdC">
33-
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
100+
<rect key="frame" x="0.0" y="64" width="320" height="568"/>
34101
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
35102
<subviews>
36103
<tableView contentMode="scaleToFill" alwaysBounceVertical="YES" dataMode="prototypes" style="plain" separatorStyle="default" rowHeight="60" sectionHeaderHeight="22" sectionFooterHeight="22" translatesAutoresizingMaskIntoConstraints="NO" id="h8l-ma-AYT">
37-
<rect key="frame" x="0.0" y="0.0" width="320" height="504"/>
104+
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
38105
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
39106
<sections/>
40107
<connections>
@@ -57,7 +124,7 @@
57124
</viewController>
58125
<placeholder placeholderIdentifier="IBFirstResponder" id="dkx-z0-nzr" sceneMemberID="firstResponder"/>
59126
</objects>
60-
<point key="canvasLocation" x="-97" y="59"/>
127+
<point key="canvasLocation" x="124" y="59"/>
61128
</scene>
62129
</scenes>
63130
<simulatedMetricsContainer key="defaultSimulatedMetrics">

PullToRefreshDemo/BeatAnimator.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class BeatAnimator: UIView, PullToRefreshViewDelegate {
3232
private let layerSeparator = CAShapeLayer()
3333

3434
override init(frame: CGRect) {
35-
3635
super.init(frame: frame)
3736

3837
layerLoader.lineWidth = 4
@@ -48,7 +47,6 @@ class BeatAnimator: UIView, PullToRefreshViewDelegate {
4847
}
4948

5049
func pullToRefresh(view: PullToRefreshView, progressDidChange progress: CGFloat) {
51-
5250
layerLoader.strokeEnd = progress
5351
}
5452

@@ -57,13 +55,10 @@ class BeatAnimator: UIView, PullToRefreshViewDelegate {
5755
}
5856

5957
func pullToRefreshAnimationDidEnd(view: PullToRefreshView) {
60-
6158
layerLoader.removeAllAnimations()
62-
6359
}
6460

6561
func pullToRefreshAnimationDidStart(view: PullToRefreshView) {
66-
6762
let pathAnimationEnd = CABasicAnimation(keyPath: "strokeEnd")
6863
pathAnimationEnd.duration = 0.5
6964
pathAnimationEnd.repeatCount = 100
@@ -82,17 +77,14 @@ class BeatAnimator: UIView, PullToRefreshViewDelegate {
8277
}
8378

8479
override func layoutSubviews() {
85-
8680
super.layoutSubviews()
87-
8881
if let superview = superview {
8982
if layerLoader.superlayer == nil {
90-
superview.layer.addSublayer(layerSeparator)
83+
superview.layer.addSublayer(layerLoader)
9184
}
9285
if layerSeparator.superlayer == nil {
9386
superview.layer.addSublayer(layerSeparator)
9487
}
95-
9688
let bezierPathLoader = UIBezierPath()
9789
bezierPathLoader.moveToPoint(CGPointMake(0, superview.frame.height - 3))
9890
bezierPathLoader.addLineToPoint(CGPoint(x: superview.frame.width, y: superview.frame.height - 3))
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// ChooseModeViewController.swift
3+
// PullToRefresh
4+
//
5+
// Created by Josip Cavar on 01/08/15.
6+
// Copyright (c) 2015 Josip Cavar. All rights reserved.
7+
//
8+
9+
import UIKit
10+
11+
class ChooseModeViewController: UIViewController {
12+
13+
override func viewDidLoad() {
14+
super.viewDidLoad()
15+
16+
// Do any additional setup after loading the view.
17+
}
18+
19+
override func didReceiveMemoryWarning() {
20+
super.didReceiveMemoryWarning()
21+
// Dispose of any resources that can be recreated.
22+
}
23+
24+
@IBAction func defaultAction(sender: AnyObject) {
25+
showControllerWithMode(.Default)
26+
}
27+
28+
@IBAction func beatAction(sender: AnyObject) {
29+
showControllerWithMode(.Beat)
30+
}
31+
32+
@IBAction func pacmanAction(sender: AnyObject) {
33+
showControllerWithMode(.Pacman)
34+
}
35+
36+
@IBAction func customAction(sender: AnyObject) {
37+
showControllerWithMode(.Custom)
38+
}
39+
40+
func showControllerWithMode(mode: ExampleMode) {
41+
if let pullToRefreshViewControler = self.storyboard?.instantiateViewControllerWithIdentifier("PullToRefreshViewController") as? PullToRefreshViewController {
42+
pullToRefreshViewControler.exampleMode = mode
43+
navigationController?.pushViewController(pullToRefreshViewControler, animated: true)
44+
}
45+
}
46+
}

PullToRefreshDemo/CustomSubview.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ class CustomSubview: UIView, PullToRefreshViewDelegate {
1515
@IBOutlet weak var activityIndicator: UIActivityIndicatorView!
1616
@IBOutlet weak var labelTitle: UILabel!
1717

18-
1918
func pullToRefreshAnimationDidStart(view: PullToRefreshView) {
20-
2119
activityIndicator.startAnimating()
2220
labelTitle.text = "Loading"
2321
}
2422

2523
func pullToRefreshAnimationDidEnd(view: PullToRefreshView) {
26-
2724
activityIndicator.stopAnimating()
2825
labelTitle.text = ""
2926
}

PullToRefreshDemo/PacmanAnimator.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ class PacmanAnimator: UIView, PullToRefreshViewDelegate {
3232
private let layerSeparator = CAShapeLayer()
3333

3434
override init(frame: CGRect) {
35-
3635
super.init(frame: frame)
3736

3837
layerLoader.lineWidth = 8
@@ -50,7 +49,6 @@ class PacmanAnimator: UIView, PullToRefreshViewDelegate {
5049
}
5150

5251
func pullToRefresh(view: PullToRefreshView, progressDidChange progress: CGFloat) {
53-
5452
layerLoader.strokeEnd = progress
5553
}
5654

@@ -59,13 +57,10 @@ class PacmanAnimator: UIView, PullToRefreshViewDelegate {
5957
}
6058

6159
func pullToRefreshAnimationDidEnd(view: PullToRefreshView) {
62-
6360
layerLoader.removeAllAnimations()
64-
6561
}
6662

6763
func pullToRefreshAnimationDidStart(view: PullToRefreshView) {
68-
6964
let pathAnimationEnd = CABasicAnimation(keyPath: "strokeEnd")
7065
pathAnimationEnd.duration = 0.5
7166
pathAnimationEnd.repeatCount = 100
@@ -84,9 +79,7 @@ class PacmanAnimator: UIView, PullToRefreshViewDelegate {
8479
}
8580

8681
override func layoutSubviews() {
87-
8882
super.layoutSubviews()
89-
9083
if let superview = superview {
9184
if layerSeparator.superlayer == nil {
9285
superview.layer.addSublayer(layerSeparator)

0 commit comments

Comments
 (0)