├── gifs
├── header.gif
├── nested.gif
├── touch.gif
└── infinite.gif
├── ScrollViewPlay
├── ScrollViewPlay
│ ├── Images.xcassets
│ │ ├── Infinite scrolling
│ │ │ ├── rocket1.imageset
│ │ │ │ ├── rocket.png
│ │ │ │ └── Contents.json
│ │ │ ├── rocket4.imageset
│ │ │ │ ├── rocket-1.png
│ │ │ │ └── Contents.json
│ │ │ ├── rocket3.imageset
│ │ │ │ ├── rocket_1__.png
│ │ │ │ └── Contents.json
│ │ │ └── rocket2.imageset
│ │ │ │ ├── space-rocket-512.png
│ │ │ │ └── Contents.json
│ │ ├── AppIcon.appiconset
│ │ │ ├── Screen Shot 2015-07-06 at 16.09.57.png
│ │ │ ├── Screen Shot 2015-07-06 at 16.09.57 2.png
│ │ │ ├── Screen Shot 2015-07-06 at 16.09.57 4.png
│ │ │ ├── Screen Shot 2015-07-06 at 16.09.57 2-1.png
│ │ │ ├── Screen Shot 2015-07-06 at 16.09.57 2-2.png
│ │ │ ├── Screen Shot 2015-07-06 at 16.09.57 2-3.png
│ │ │ └── Contents.json
│ │ └── Header View Zooming
│ │ │ ├── stars.imageset
│ │ │ ├── hubble-space-wallpapers.jpg
│ │ │ └── Contents.json
│ │ │ └── rockets.imageset
│ │ │ ├── 2000px-Flag_of_Romania.svg.png
│ │ │ └── Contents.json
│ ├── ScrollViewPlay-BridgingHeader.h
│ ├── HeaderZoomViewController.swift
│ ├── OverlayScrollView.swift
│ ├── InfiniteScrollViewController.swift
│ ├── TouchDelayRecognizer.swift
│ ├── Info.plist
│ ├── AppDelegate.swift
│ ├── TableViewController.swift
│ ├── DynamicCollectionLayout.swift
│ ├── DotView.swift
│ ├── HeaderZoomScrollView.swift
│ ├── NestedScrollViewController.swift
│ ├── Base.lproj
│ │ ├── LaunchScreen.xib
│ │ └── Main.storyboard
│ ├── ScrollableCell.swift
│ ├── ScrollTouchViewController.swift
│ └── InfiniteScrollView.swift
├── ScrollViewPlay.xcodeproj
│ ├── project.xcworkspace
│ │ └── contents.xcworkspacedata
│ └── project.pbxproj
├── ScrollViewPlay-BridgingHeader.h
└── ScrollViewPlayTests
│ ├── Info.plist
│ └── ScrollViewPlayTests.swift
├── .gitignore
├── README.md
└── LICENSE
/gifs/header.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/gifs/header.gif
--------------------------------------------------------------------------------
/gifs/nested.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/gifs/nested.gif
--------------------------------------------------------------------------------
/gifs/touch.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/gifs/touch.gif
--------------------------------------------------------------------------------
/gifs/infinite.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/gifs/infinite.gif
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket1.imageset/rocket.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket1.imageset/rocket.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket4.imageset/rocket-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket4.imageset/rocket-1.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket3.imageset/rocket_1__.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket3.imageset/rocket_1__.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket2.imageset/space-rocket-512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket2.imageset/space-rocket-512.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 2.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 4.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 4.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 2-1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 2-1.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 2-2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 2-2.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 2-3.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Screen Shot 2015-07-06 at 16.09.57 2-3.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Header View Zooming/stars.imageset/hubble-space-wallpapers.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Header View Zooming/stars.imageset/hubble-space-wallpapers.jpg
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Header View Zooming/rockets.imageset/2000px-Flag_of_Romania.svg.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/teodorpatras/SrollViewPlay/HEAD/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Header View Zooming/rockets.imageset/2000px-Flag_of_Romania.svg.png
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay-BridgingHeader.h:
--------------------------------------------------------------------------------
1 | //
2 | // ScrollViewPlay-BridgingHeader.h
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 05/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | #import
10 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/ScrollViewPlay-BridgingHeader.h:
--------------------------------------------------------------------------------
1 | //
2 | // ScrollViewPlay-BridgingHeader.h
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 05/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | #import
10 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket1.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "rocket.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket3.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "rocket_1__.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket4.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "rocket-1.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Infinite scrolling/rocket2.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x",
10 | "filename" : "space-rocket-512.png"
11 | },
12 | {
13 | "idiom" : "universal",
14 | "scale" : "3x"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Header View Zooming/stars.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "scale" : "3x",
14 | "filename" : "hubble-space-wallpapers.jpg"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/Header View Zooming/rockets.imageset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "universal",
5 | "scale" : "1x"
6 | },
7 | {
8 | "idiom" : "universal",
9 | "scale" : "2x"
10 | },
11 | {
12 | "idiom" : "universal",
13 | "scale" : "3x",
14 | "filename" : "2000px-Flag_of_Romania.svg.png"
15 | }
16 | ],
17 | "info" : {
18 | "version" : 1,
19 | "author" : "xcode"
20 | }
21 | }
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/HeaderZoomViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HeaderZoomViewController.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 02/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class HeaderZoomViewController: UIViewController {
12 |
13 |
14 | @IBOutlet weak var scrollView: HeaderZoomScrollView!
15 |
16 | override func viewDidLoad() {
17 | super.viewDidLoad()
18 |
19 | self.navigationItem.title = "Header view & Zooming";
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/OverlayScrollView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OverlayScrollView.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 05/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class OverlayScrollView: UIScrollView {
12 |
13 | override func hitTest(point: CGPoint, withEvent event: UIEvent?) -> UIView? {
14 | let view = super.hitTest(point, withEvent: event)
15 |
16 | if view == self {
17 | return nil
18 | }
19 |
20 | return view
21 | }
22 |
23 | }
24 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | # Pods/
27 |
28 | # Carthage
29 | #
30 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
31 | # Carthage/Checkouts
32 |
33 | Carthage/Build
34 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SrollViewPlay
2 | Some UIScrollView techniques from the WWDC videos. Written in Swift. Demos implemented:
3 |
4 | ## Infinite scrolling
5 |
6 | Example of infinite scrolling through 4 static image views.
7 |
8 | 
9 |
10 | ## Header view & zooming
11 |
12 | Example of zooming one of the scroll view subviews and keeping a second one as a header view.
13 |
14 | 
15 |
16 | ## Nested scroll views
17 |
18 | Example of nested scrollviews where an inner one pulls the outer one.
19 |
20 | 
21 |
22 | ## Scroll views touch events handling
23 |
24 | Example of handling different touch events between a scroll view, its subview and its sibling.
25 |
26 | 
27 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlayTests/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | teodorpatras.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | BNDL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 |
24 |
25 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/InfiniteScrollViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // InfiniteScrollViewController.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 02/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class InfiniteScrollViewController: UIViewController {
12 |
13 | override func viewDidLoad() {
14 | super.viewDidLoad()
15 |
16 | self.navigationItem.title = "Infinite scrolling"
17 | }
18 |
19 | override func didReceiveMemoryWarning() {
20 | super.didReceiveMemoryWarning()
21 | // Dispose of any resources that can be recreated.
22 | }
23 |
24 |
25 | /*
26 | // MARK: - Navigation
27 |
28 | // In a storyboard-based application, you will often want to do a little preparation before navigation
29 | override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
30 | // Get the new view controller using segue.destinationViewController.
31 | // Pass the selected object to the new view controller.
32 | }
33 | */
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlayTests/ScrollViewPlayTests.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ScrollViewPlayTests.swift
3 | // ScrollViewPlayTests
4 | //
5 | // Created by Teodor Patras on 02/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 | import XCTest
11 |
12 | class ScrollViewPlayTests: XCTestCase {
13 |
14 | override func setUp() {
15 | super.setUp()
16 | // Put setup code here. This method is called before the invocation of each test method in the class.
17 | }
18 |
19 | override func tearDown() {
20 | // Put teardown code here. This method is called after the invocation of each test method in the class.
21 | super.tearDown()
22 | }
23 |
24 | func testExample() {
25 | // This is an example of a functional test case.
26 | XCTAssert(true, "Pass")
27 | }
28 |
29 | func testPerformanceExample() {
30 | // This is an example of a performance test case.
31 | self.measureBlock() {
32 | // Put the code you want to measure the time of here.
33 | }
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Teodor Patraş
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "29x29",
5 | "idiom" : "iphone",
6 | "filename" : "Screen Shot 2015-07-06 at 16.09.57 2.png",
7 | "scale" : "2x"
8 | },
9 | {
10 | "size" : "29x29",
11 | "idiom" : "iphone",
12 | "filename" : "Screen Shot 2015-07-06 at 16.09.57 4.png",
13 | "scale" : "3x"
14 | },
15 | {
16 | "size" : "40x40",
17 | "idiom" : "iphone",
18 | "filename" : "Screen Shot 2015-07-06 at 16.09.57 2-3.png",
19 | "scale" : "2x"
20 | },
21 | {
22 | "size" : "40x40",
23 | "idiom" : "iphone",
24 | "filename" : "Screen Shot 2015-07-06 at 16.09.57 2-1.png",
25 | "scale" : "3x"
26 | },
27 | {
28 | "size" : "60x60",
29 | "idiom" : "iphone",
30 | "filename" : "Screen Shot 2015-07-06 at 16.09.57 2-2.png",
31 | "scale" : "2x"
32 | },
33 | {
34 | "size" : "60x60",
35 | "idiom" : "iphone",
36 | "filename" : "Screen Shot 2015-07-06 at 16.09.57.png",
37 | "scale" : "3x"
38 | }
39 | ],
40 | "info" : {
41 | "version" : 1,
42 | "author" : "xcode"
43 | }
44 | }
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/TouchDelayRecognizer.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TouchDelayRecognizer.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 05/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class TouchDelayRecognizer: UIGestureRecognizer {
12 |
13 | var timer : NSTimer?
14 |
15 | override init(target: AnyObject, action: Selector) {
16 | super.init(target: target, action: action)
17 | self.delaysTouchesBegan = true
18 | }
19 |
20 | func fail () {
21 | self.state = .Failed
22 | }
23 |
24 | override func reset () {
25 | timer?.invalidate()
26 | timer = nil
27 | }
28 |
29 | override func touchesBegan(touches: Set, withEvent event: UIEvent) {
30 | timer = NSTimer.scheduledTimerWithTimeInterval(0.15, target: self, selector: "fail", userInfo: nil, repeats: false)
31 | }
32 |
33 | override func touchesEnded(touches: Set, withEvent event: UIEvent) {
34 | self.fail()
35 | }
36 |
37 | override func touchesCancelled(touches: Set!, withEvent event: UIEvent!) {
38 | self.fail()
39 | }
40 | }
41 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | teodorpatras.$(PRODUCT_NAME:rfc1034identifier)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleSignature
20 | ????
21 | CFBundleVersion
22 | 1
23 | LSRequiresIPhoneOS
24 |
25 | UILaunchStoryboardName
26 | LaunchScreen
27 | UIMainStoryboardFile
28 | Main
29 | UIRequiredDeviceCapabilities
30 |
31 | armv7
32 |
33 | UISupportedInterfaceOrientations
34 |
35 | UIInterfaceOrientationPortrait
36 |
37 | UISupportedInterfaceOrientations~ipad
38 |
39 | UIInterfaceOrientationPortrait
40 | UIInterfaceOrientationPortraitUpsideDown
41 | UIInterfaceOrientationLandscapeLeft
42 | UIInterfaceOrientationLandscapeRight
43 |
44 |
45 |
46 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 02/07/15.
6 | // Copyright (c) 2015 Teodor Patras. 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: [NSObject: AnyObject]?) -> 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 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/TableViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // TableViewController.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 02/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | func statusAndNavigationBarHeights(controller : UINavigationController) -> CGFloat{
12 | return UIApplication.sharedApplication().statusBarFrame.height + controller.navigationBar.frame.size.height
13 | }
14 |
15 | class TableViewController: UITableViewController {
16 |
17 | let dataSource = [["title" : "Infinite scrolling", "segue" : "showInfiniteScrollView"],["title" : "Header View & Zooming", "segue" : "showHeaderZoomScrollView"], ["title" : "Nested scroll views", "segue" : "showNestedScrollViews"], ["title" : "Scroll view touch handling", "segue" : "showScrollTouchController"]]
18 |
19 | override func viewDidLoad() {
20 | super.viewDidLoad()
21 |
22 | self.navigationItem.title = "Overview"
23 | self.navigationController?.navigationBar.translucent = false
24 |
25 | // Uncomment the following line to preserve selection between presentations
26 | // self.clearsSelectionOnViewWillAppear = false
27 |
28 | // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
29 | // self.navigationItem.rightBarButtonItem = self.editButtonItem()
30 | }
31 |
32 | override func didReceiveMemoryWarning() {
33 | super.didReceiveMemoryWarning()
34 | // Dispose of any resources that can be recreated.
35 | }
36 |
37 | // MARK: - Table view data source
38 |
39 | override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
40 | // #warning Potentially incomplete method implementation.
41 | // Return the number of sections.
42 | return 1
43 | }
44 |
45 | override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
46 | // #warning Incomplete method implementation.
47 | // Return the number of rows in the section.
48 | return dataSource.count
49 | }
50 |
51 | override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
52 | let cell = tableView.dequeueReusableCellWithIdentifier("myCell", forIndexPath: indexPath) as! UITableViewCell
53 |
54 | cell.textLabel?.text = dataSource[indexPath.row]["title"]
55 |
56 | return cell
57 | }
58 |
59 | override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
60 | tableView.deselectRowAtIndexPath(indexPath, animated: true)
61 | self.performSegueWithIdentifier(dataSource[indexPath.row]["segue"], sender: nil)
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/DynamicCollectionLayout.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DynamicCollectionLayout.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 05/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class DynamicCollectionLayout: UICollectionViewFlowLayout {
12 |
13 | var animator : UIDynamicAnimator!
14 |
15 | override func prepareLayout() {
16 | super.prepareLayout()
17 |
18 | if animator == nil {
19 | animator = UIDynamicAnimator(collectionViewLayout: self)
20 | /*
21 | This needs to be optimised in a real life application
22 | use UIDynamicAnimator's
23 |
24 | func addBehavior(behavior: UIDynamicBehavior!)
25 | func removeBehavior(behavior: UIDynamicBehavior!)
26 |
27 | To add only the visible items at a given time and remove the other ones
28 | which are not visible anymore
29 |
30 | */
31 | let contentSize = self.collectionViewContentSize()
32 | let items = super.layoutAttributesForElementsInRect(CGRectMake(0, 0, contentSize.width, contentSize.height)) as! [UICollectionViewLayoutAttributes]
33 |
34 | for item in items {
35 | let spring = UIAttachmentBehavior(item: item, attachedToAnchor: item.center)
36 |
37 | spring.length = 0
38 | spring.damping = 0.5
39 | spring.frequency = 0.8
40 |
41 | animator.addBehavior(spring)
42 | }
43 | }
44 | }
45 |
46 | override func layoutAttributesForItemAtIndexPath(indexPath: NSIndexPath) -> UICollectionViewLayoutAttributes! {
47 | return animator.layoutAttributesForCellAtIndexPath(indexPath)
48 | }
49 |
50 | override func layoutAttributesForElementsInRect(rect: CGRect) -> [AnyObject]? {
51 | return animator.itemsInRect(rect)
52 | }
53 |
54 | override func shouldInvalidateLayoutForBoundsChange(newBounds: CGRect) -> Bool {
55 | let scrollDelta = newBounds.origin.y - self.collectionView!.bounds.origin.y
56 | let touchLocation = self.collectionView!.panGestureRecognizer.locationInView(self.collectionView!)
57 |
58 | for spring in animator.behaviors {
59 | let item = (spring as! UIAttachmentBehavior).items.first as! UICollectionViewLayoutAttributes
60 |
61 | let anchorPoint = (spring as! UIAttachmentBehavior).anchorPoint
62 | let distanceFromTouch = fabs(touchLocation.y - anchorPoint.y)
63 | let scrollResistance = distanceFromTouch / 750
64 |
65 | var center = item.center
66 | center.y += scrollDelta * scrollResistance
67 | item.center = center
68 |
69 | animator.updateItemUsingCurrentState(item)
70 | }
71 |
72 | return false
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/DotView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // DotView.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 05/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class DotView: UIView {
12 |
13 | var color = UIColor.whiteColor()
14 | var highlightColor = UIColor.blackColor()
15 |
16 | class func placeRandomViewsWithinSuperview(superview : UIView, numberOfViews : Int, target : UIGestureRecognizerDelegate?, selector: Selector?)
17 | {
18 | for i in 1...numberOfViews {
19 | let randomDim = CGFloat(max(10, arc4random() % 100))
20 | let bounds = superview.bounds
21 | let randomYCenter = max (randomDim / 2 + 10, CGFloat(arc4random()) % (bounds.size.height - randomDim / 2))
22 | let randomXCenter = max (randomDim / 2 + 10, CGFloat(arc4random()) % (bounds.size.width - randomDim / 2))
23 |
24 | let view = DotView(frame: CGRectMake(0, 0, randomDim, randomDim))
25 | view.center = CGPointMake(randomXCenter, randomYCenter)
26 | superview.addSubview(view)
27 |
28 | view.backgroundColor = randomColor()
29 | view.color = view.backgroundColor!
30 | view.highlightColor = view.darkerColor()
31 |
32 | view.layer.cornerRadius = randomDim / 2
33 |
34 | if let t = target, let s = selector {
35 | let gesture = UILongPressGestureRecognizer(target: t, action: s)
36 | view.addGestureRecognizer(gesture)
37 | gesture.cancelsTouchesInView = false
38 | gesture.delegate = target
39 | }
40 | }
41 | }
42 |
43 | func darkerColor() -> UIColor{
44 |
45 | var r:CGFloat = 0
46 | var g:CGFloat = 0
47 | var b:CGFloat = 0
48 | var a:CGFloat = 0
49 | color.getRed(&r, green: &g, blue: &b, alpha: &a)
50 |
51 | let darkeningFactor : CGFloat = 0.3
52 |
53 | return UIColor(red: max (r - darkeningFactor, 0.0), green: max (0.0, g - darkeningFactor), blue: max(b - darkeningFactor, 0.0), alpha: a)
54 | }
55 |
56 | override func touchesBegan(touches: Set, withEvent event: UIEvent) {
57 | self.backgroundColor = self.highlightColor
58 | }
59 |
60 | override func touchesEnded(touches: Set, withEvent event: UIEvent) {
61 | self.backgroundColor = color
62 | }
63 |
64 | override func touchesCancelled(touches: Set!, withEvent event: UIEvent!) {
65 | self.backgroundColor = color
66 | }
67 |
68 | override func pointInside(point: CGPoint, withEvent event: UIEvent?) -> Bool {
69 | var touchBounds = self.bounds
70 | if CGRectGetWidth(touchBounds) < 44 {
71 | let expansion = 44 - CGRectGetWidth(touchBounds)
72 | touchBounds = CGRectInset(touchBounds, -expansion, -expansion)
73 | }
74 |
75 | return CGRectContainsPoint(touchBounds, point)
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/HeaderZoomScrollView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // HeaderZoomScrollView.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 02/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class HeaderZoomScrollView: UIScrollView, UIScrollViewDelegate {
12 |
13 |
14 | // MARK:- Subviews -
15 |
16 | let rocketsView : UIImageView
17 | let starsView : UIImageView
18 |
19 | // MARK:- Constants -
20 |
21 | let topMargin : CGFloat = 0
22 | let rocketsTopMargin : CGFloat = 10
23 | let rocketsRightMargin : CGFloat = 20
24 |
25 | // MARK:- Helper variables -
26 |
27 | var referenceZoomScale : CGFloat = 0
28 |
29 | // MARK:- Initializer -
30 |
31 | required init(coder aDecoder: NSCoder) {
32 |
33 | rocketsView = UIImageView(image: UIImage(named: "rockets"))
34 | starsView = UIImageView (image: UIImage(named: "stars"))
35 |
36 | super.init(coder: aDecoder)
37 |
38 | self.contentSize = starsView.frame.size
39 |
40 |
41 | let screenBounds = UIScreen.mainScreen().bounds
42 |
43 | starsView.frame = CGRectMake(0, topMargin, CGRectGetWidth(starsView.frame), CGRectGetHeight(starsView.frame))
44 |
45 | rocketsView.frame = CGRectMake(CGRectGetWidth(screenBounds) - rocketsRightMargin - CGRectGetWidth(rocketsView.frame), rocketsTopMargin, CGRectGetWidth(rocketsView.frame), CGRectGetHeight(rocketsView.frame))
46 |
47 | self.addSubview(starsView)
48 | self.addSubview(rocketsView)
49 |
50 | self.delegate = self
51 | self.minimumZoomScale = 1.0
52 | self.maximumZoomScale = 8
53 | }
54 |
55 | // MARK:- Layout -
56 |
57 | override func setZoomScale(scale: CGFloat, animated: Bool) {
58 | super.setZoomScale(scale, animated: animated)
59 | referenceZoomScale = self.zoomScale
60 | }
61 |
62 | override func layoutSubviews() {
63 | super.layoutSubviews()
64 |
65 | let visibleBounds = self.convertRect(self.bounds, toView: self.starsView)
66 |
67 | /*
68 | let maxVisibleX = CGRectGetMaxX(visibleBounds)
69 | let minVisibleX = CGRectGetMinX(visibleBounds)
70 | */
71 |
72 | let moonCenterX = CGRectGetMaxX(self.bounds) - rocketsRightMargin - CGRectGetWidth(rocketsView.frame) / 2
73 | let moonCenterY = self.contentOffset.y + 10 + CGRectGetHeight(rocketsView.frame) / 2
74 |
75 | rocketsView.center = CGPointMake(moonCenterX, CGRectGetHeight(rocketsView.frame) / 2 + rocketsTopMargin)
76 | }
77 |
78 | // MARK:- UIScrollviewDelegate -
79 |
80 |
81 | func viewForZoomingInScrollView(scrollView: UIScrollView) -> UIView? {
82 | return starsView
83 | }
84 |
85 | func scrollViewDidEndZooming(scrollView: UIScrollView, withView view: UIView!, atScale scale: CGFloat) {
86 | // redraw after zooming
87 |
88 | let s = scale * scrollView.window!.screen.scale
89 | starsView.contentScaleFactor = scale
90 | }
91 | }
92 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/NestedScrollViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // NestedScrollViewController.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 05/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class NestedScrollViewController: UIViewController, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout, ScrollableCellDelegate {
12 |
13 | @IBOutlet weak var scrollView: UIScrollView!
14 | @IBOutlet weak var collectionView: UICollectionView!
15 |
16 | var secondPageView : UIView!
17 |
18 | override func viewDidLoad() {
19 | super.viewDidLoad()
20 |
21 | self.navigationItem.title = "Nested scroll views"
22 |
23 | var frame = UIScreen.mainScreen().bounds
24 | frame.origin.x += frame.size.width
25 |
26 | secondPageView = UIView(frame: frame)
27 |
28 | secondPageView.backgroundColor = UIColor.redColor()
29 | scrollView.addSubview(secondPageView)
30 |
31 | self.collectionView.backgroundColor = UIColor.clearColor()
32 | self.collectionView.collectionViewLayout = DynamicCollectionLayout()
33 | }
34 |
35 | override func viewDidAppear(animated: Bool) {
36 | super.viewDidAppear(animated)
37 |
38 | self.scrollView.contentSize = CGSizeMake(scrollView.frame.size.width * 2, scrollView.frame.size.height)
39 | }
40 |
41 | // MARK:- UICollectionView DataSource & Delegate -
42 |
43 | func collectionView(collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int
44 | {
45 | return 100
46 | }
47 |
48 | func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell {
49 | let cell = collectionView.dequeueReusableCellWithReuseIdentifier("scrollCell", forIndexPath: indexPath) as! ScrollableCell
50 |
51 | cell.dragView.backgroundColor = randomColor()
52 | cell.delegate = self
53 |
54 | return cell
55 | }
56 |
57 | func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAtIndexPath indexPath: NSIndexPath) -> CGSize {
58 | return CGSizeMake(collectionView.bounds.size.width, 60)
59 | }
60 |
61 | func collectionView(collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAtIndex section: Int) -> CGFloat {
62 | return 10
63 | }
64 |
65 | // MARK:- ScrollableCellDelegate -
66 |
67 | func scrollableCellDidBeginPulling(cell: ScrollableCell) {
68 | self.scrollView.scrollEnabled = false
69 |
70 | self.secondPageView.backgroundColor = cell.dragView.backgroundColor
71 | }
72 |
73 | func scrollableCellDidChangePullOffset(cell: ScrollableCell, offset: CGFloat) {
74 | self.scrollView.contentOffset = CGPointMake(offset, 0)
75 | }
76 |
77 | func scrollableCellDidEndPulling(cell: ScrollableCell) {
78 | self.scrollView.scrollEnabled = true
79 | }
80 | }
81 |
82 | func randomColor() -> UIColor{
83 |
84 | var randomRed:CGFloat = CGFloat(drand48())
85 |
86 | var randomGreen:CGFloat = CGFloat(drand48())
87 |
88 | var randomBlue:CGFloat = CGFloat(drand48())
89 |
90 | return UIColor(red: randomRed, green: randomGreen, blue: randomBlue, alpha: 1.0)
91 |
92 | }
93 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Base.lproj/LaunchScreen.xib:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
20 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/ScrollableCell.swift:
--------------------------------------------------------------------------------
1 |
2 | //
3 | // ScrollableCell.swift
4 | // ScrollViewPlay
5 | //
6 | // Created by Teodor Patras on 05/07/15.
7 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
8 | //
9 |
10 | import UIKit
11 |
12 | class ScrollableCell: UICollectionViewCell, UIScrollViewDelegate {
13 |
14 |
15 | var scrollView: UIScrollView!
16 | var dragView: UIView!
17 | var label : UILabel!
18 |
19 | weak var delegate : ScrollableCellDelegate?
20 |
21 | var pulling = false
22 | var deceleratingBackToZero = false
23 |
24 | var decelerationDistanceRatio : CGFloat = 0
25 | let pullThreshold : CGFloat = 100
26 |
27 | override func awakeFromNib() {
28 |
29 | scrollView = UIScrollView()
30 | dragView = UIView()
31 | label = UILabel()
32 |
33 | label.font = UIFont(name: "HelveticaNeue-Light", size: 20)
34 | label.backgroundColor = UIColor.clearColor()
35 | label.text = "Slide from right to left"
36 | label.textAlignment = NSTextAlignment.Center
37 |
38 | self.scrollView.delegate = self
39 | self.scrollView.pagingEnabled = true
40 | self.scrollView.showsHorizontalScrollIndicator = false
41 |
42 | self.addSubview(self.scrollView)
43 | self.dragView.addSubview(label)
44 | self.scrollView.addSubview(dragView)
45 | }
46 |
47 | override func layoutSubviews() {
48 |
49 | let contentView = self.contentView
50 | let bounds = self.bounds
51 | let pageWidth = bounds.size.width + pullThreshold
52 |
53 | self.scrollView.frame = CGRectMake(0, 0, pageWidth, bounds.size.height)
54 | self.scrollView.contentSize = CGSizeMake(pageWidth * 2, bounds.size.height)
55 |
56 | dragView.frame = bounds
57 | label.frame = bounds
58 | }
59 |
60 | // MARK:- UIScrollViewDelegate -
61 |
62 | func scrollViewDidScroll(scrollView: UIScrollView) {
63 | let offset = scrollView.contentOffset.x
64 |
65 | if offset > pullThreshold && !pulling {
66 | // did start pulling
67 | self.delegate?.scrollableCellDidBeginPulling(self)
68 | pulling = true
69 | }
70 |
71 | if pulling {
72 | var pullOffset = CGFloat(0)
73 |
74 | if deceleratingBackToZero{
75 | pullOffset = offset * decelerationDistanceRatio
76 | } else {
77 | pullOffset = max(0, offset - pullThreshold)
78 | }
79 |
80 | self.delegate?.scrollableCellDidChangePullOffset(self, offset: pullOffset)
81 | self.dragView.transform = CGAffineTransformMakeTranslation(pullOffset, 0)
82 | }
83 | }
84 |
85 | func scrollViewDidEndDecelerating(scrollView: UIScrollView) {
86 | self.scrollingEnded()
87 | }
88 |
89 | func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) {
90 | if !decelerate {
91 | self.scrollingEnded()
92 | }
93 | }
94 |
95 | func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer) {
96 |
97 | let offset = scrollView.contentOffset.x
98 |
99 | if targetContentOffset.memory.x == 0 && offset > 0 {
100 | deceleratingBackToZero = true
101 | let pullOffset = max(0, offset - pullThreshold)
102 | decelerationDistanceRatio = pullOffset / offset
103 | }
104 | }
105 |
106 | func scrollingEnded ()
107 | {
108 | deceleratingBackToZero = false
109 | pulling = false
110 | self.delegate?.scrollableCellDidEndPulling(self)
111 | self.scrollView.contentOffset = CGPointZero
112 | self.dragView.transform = CGAffineTransformIdentity
113 | }
114 | }
115 |
116 | @objc protocol ScrollableCellDelegate {
117 | func scrollableCellDidBeginPulling(cell : ScrollableCell)
118 | func scrollableCellDidChangePullOffset(cell : ScrollableCell, offset : CGFloat)
119 | func scrollableCellDidEndPulling(cell : ScrollableCell)
120 | }
121 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/ScrollTouchViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ScrollTouchViewController.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 05/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class ScrollTouchViewController: UIViewController, UIGestureRecognizerDelegate {
12 |
13 | var dotViewsPlaced = false
14 | var canvasView : UIView!
15 | var scrollView : OverlayScrollView!
16 | var drawerView : UIVisualEffectView!
17 |
18 | override func viewDidLoad() {
19 | super.viewDidLoad()
20 |
21 | canvasView = UIView()
22 | scrollView = OverlayScrollView()
23 | drawerView = UIVisualEffectView(effect: UIBlurEffect(style: UIBlurEffectStyle.Dark))
24 |
25 | scrollView.addSubview(drawerView)
26 | self.view.addSubview(canvasView)
27 | self.view.addSubview(scrollView)
28 |
29 | self.scrollView.showsVerticalScrollIndicator = false
30 |
31 | self.view.addGestureRecognizer(scrollView.panGestureRecognizer)
32 |
33 | self.canvasView.addGestureRecognizer(TouchDelayRecognizer(target: self, action: ""))
34 |
35 | self.navigationItem.title = "Touch events handling"
36 |
37 | }
38 |
39 | override func viewDidLayoutSubviews() {
40 |
41 | canvasView.frame = self.view.bounds
42 | scrollView.frame = self.view.bounds
43 |
44 | if !dotViewsPlaced {
45 |
46 | drawerView.frame = CGRectMake(0, 0, self.view.bounds.size.width, 350)
47 |
48 |
49 | scrollView.contentSize = CGSizeMake(self.view.bounds.size.width, self.view.bounds.size.height + drawerView.bounds.size.height)
50 |
51 | scrollView.contentOffset = CGPointMake(0, drawerView.bounds.size.height)
52 |
53 | dotViewsPlaced = true
54 |
55 | DotView.placeRandomViewsWithinSuperview(self.canvasView, numberOfViews: 15, target: self, selector: "handleLongPress:")
56 | DotView.placeRandomViewsWithinSuperview(self.drawerView.contentView, numberOfViews: 5, target: self, selector: "handleLongPress:")
57 | }
58 | }
59 |
60 | func handleLongPress(gesture : UILongPressGestureRecognizer){
61 | let dot = gesture.view as! DotView
62 |
63 | switch gesture.state {
64 | case .Began :
65 | grabDot(dot, gestureRecognizer: gesture)
66 | case .Changed :
67 | moveDot(dot, gestureRecognizer: gesture)
68 | case .Cancelled, .Ended :
69 | dropDot(dot, gestureRecognizer: gesture)
70 | default :
71 | break
72 | }
73 | }
74 |
75 | func grabDot(dot : DotView, gestureRecognizer : UILongPressGestureRecognizer){
76 |
77 | dot.center = self.view.convertPoint(dot.center, fromView: dot.superview)
78 | self.view.addSubview(dot)
79 |
80 | UIView.animateWithDuration(0.3, animations: { () -> Void in
81 | dot.transform = CGAffineTransformMakeScale(1.2, 1.2)
82 | dot.alpha = 0.8
83 | self.moveDot(dot, gestureRecognizer: gestureRecognizer)
84 | })
85 |
86 | // get the touch away from the pan gesture
87 |
88 | self.scrollView.panGestureRecognizer.enabled = false
89 | self.scrollView.panGestureRecognizer.enabled = true
90 | }
91 |
92 | func moveDot(dot : DotView, gestureRecognizer : UILongPressGestureRecognizer){
93 | dot.center = gestureRecognizer.locationInView(self.view)
94 | }
95 |
96 | func dropDot(dot : DotView, gestureRecognizer : UILongPressGestureRecognizer){
97 | UIView.animateWithDuration(0.3, animations: { () -> Void in
98 | dot.transform = CGAffineTransformIdentity
99 | dot.alpha = 1
100 | })
101 |
102 | let location = gestureRecognizer.locationInView(drawerView)
103 |
104 | if CGRectContainsPoint(drawerView.bounds, location) {
105 | drawerView.contentView.addSubview(dot)
106 | } else {
107 | canvasView.addSubview(dot)
108 | }
109 |
110 | dot.center = self.view.convertPoint(dot.center, toView: dot.superview)
111 | }
112 |
113 | func gestureRecognizer(gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWithGestureRecognizer otherGestureRecognizer: UIGestureRecognizer) -> Bool {
114 | return otherGestureRecognizer == self.scrollView.panGestureRecognizer
115 | }
116 | }
117 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/InfiniteScrollView.swift:
--------------------------------------------------------------------------------
1 | //
2 | // InfiniteScrollView.swift
3 | // ScrollViewPlay
4 | //
5 | // Created by Teodor Patras on 02/07/15.
6 | // Copyright (c) 2015 Teodor Patras. All rights reserved.
7 | //
8 |
9 | import UIKit
10 |
11 | class InfiniteScrollView: UIScrollView {
12 |
13 | let containerView : UIView
14 | let imageNames = ["rocket1", "rocket4", "rocket2", "rocket3"]
15 | var imageViews = [UIImageView]()
16 | var visibleImageViews = [UIImageView]()
17 |
18 | required init(coder aDecoder: NSCoder) {
19 |
20 | containerView = UIView()
21 |
22 | super.init(coder: aDecoder)
23 |
24 | self.contentSize = CGSizeMake(5000, UIScreen.mainScreen().bounds.height - 128)
25 | containerView.frame = CGRectMake(0, 0, self.contentSize.width, self.contentSize.height * 0.7)
26 | self.addSubview(self.containerView)
27 |
28 | var actualSize : CGFloat = 0
29 | var imageView : UIImageView
30 |
31 | for name in imageNames
32 | {
33 | imageView = UIImageView(image: UIImage(named: name))
34 | actualSize += CGRectGetWidth(imageView.frame)
35 | imageViews.append(imageView)
36 | }
37 |
38 | /* this should only work if all the images place side by side would
39 | not fit within the width of the scroll view */
40 |
41 | if actualSize <= CGRectGetWidth(self.bounds) {
42 | self.scrollEnabled = false
43 | self.bounces = false
44 | }
45 |
46 | }
47 |
48 | // MARK:- Layout -
49 |
50 | func recenterIfNecessary ()
51 | {
52 | let centerOffsetX = (self.contentSize.width - self.bounds.size.width) / 2
53 | let distanceFromCenter = fabs(self.contentOffset.x - centerOffsetX)
54 |
55 | if distanceFromCenter > self.contentSize.width / 4 {
56 |
57 |
58 | // move all the views by the same amount so they appear still
59 |
60 | for imageView in self.visibleImageViews
61 | {
62 | var center = self.containerView.convertPoint(imageView.center, toView: self)
63 | center.x += centerOffsetX - self.contentOffset.x
64 |
65 | imageView.center = self.convertPoint(center, toView: self.containerView)
66 | }
67 |
68 | self.contentOffset = CGPointMake(centerOffsetX, self.contentOffset.y)
69 | }
70 | }
71 |
72 | override func layoutSubviews() {
73 | super.layoutSubviews()
74 |
75 | self.recenterIfNecessary()
76 |
77 | // tile content in visible bounds
78 |
79 | let visibleBounds = self.convertRect(self.bounds, toView: self.containerView)
80 | let minVisX = CGRectGetMinX(visibleBounds)
81 | let maxVisX = CGRectGetMaxX(visibleBounds)
82 |
83 | self.tileFromMinX(minVisX, toMaxX: maxVisX)
84 | }
85 |
86 | // MARK:- UIImageViews Tiling -
87 |
88 |
89 | func placeImageViewOnRight(imageView : UIImageView, rightEdge : CGFloat) -> CGFloat {
90 |
91 | var frame = imageView.frame
92 | frame.origin.x = rightEdge
93 | frame.origin.y = CGRectGetHeight(self.containerView.bounds) - frame.size.height
94 | imageView.frame = frame
95 |
96 | self.containerView.addSubview(imageView)
97 | self.visibleImageViews.append(imageView)
98 |
99 | return CGRectGetMaxX(frame)
100 | }
101 |
102 | func placeImageViewOnLeft(imageView : UIImageView, leftEdge : CGFloat) -> CGFloat {
103 |
104 | var frame = imageView.frame
105 | frame.origin.x = leftEdge - CGRectGetWidth(frame)
106 | frame.origin.y = CGRectGetHeight(self.containerView.bounds) - frame.size.height
107 | imageView.frame = frame
108 |
109 | self.containerView.addSubview(imageView)
110 | self.visibleImageViews.insert(imageView, atIndex: 0)
111 |
112 | return CGRectGetMinX(frame)
113 | }
114 |
115 | func tileFromMinX(minVisX : CGFloat, toMaxX maxX: CGFloat) {
116 |
117 |
118 | // place the first image
119 |
120 | if visibleImageViews.count == 0 {
121 | var imageView = imageViews.removeAtIndex(0)
122 | self.placeImageViewOnRight(imageView, rightEdge: minVisX)
123 | }
124 |
125 |
126 | // place missing images on the right edge
127 |
128 | var shouldPlaceSomeMore = true
129 | var newXOrigin = CGRectGetMaxX(self.visibleImageViews.last!.frame)
130 |
131 | while shouldPlaceSomeMore
132 | {
133 | shouldPlaceSomeMore = false
134 | if newXOrigin < maxX
135 | {
136 | if let iv = imageViews.last
137 | {
138 | newXOrigin = self.placeImageViewOnRight(iv, rightEdge: newXOrigin)
139 | imageViews.removeLast()
140 | shouldPlaceSomeMore = newXOrigin < maxX
141 | }
142 | }
143 | }
144 |
145 |
146 | // place missing images on the left edge
147 |
148 | shouldPlaceSomeMore = true
149 | newXOrigin = CGRectGetMinX(self.visibleImageViews.first!.frame)
150 |
151 | while shouldPlaceSomeMore
152 | {
153 | shouldPlaceSomeMore = false
154 | if newXOrigin > minVisX {
155 | if let iv = imageViews.first
156 | {
157 | newXOrigin = self.placeImageViewOnLeft(iv, leftEdge: newXOrigin)
158 | imageViews.removeAtIndex(0)
159 | shouldPlaceSomeMore = newXOrigin > minVisX
160 | }
161 | }
162 | }
163 |
164 | // remove images that have fallen over the right edge
165 |
166 | var shouldRemove = true
167 |
168 | while shouldRemove
169 | {
170 | shouldRemove = false
171 | if let iv = visibleImageViews.last
172 | {
173 | if CGRectGetMinX(iv.frame) > maxX {
174 | imageViews.append(iv)
175 | iv.removeFromSuperview()
176 | shouldRemove = true
177 | visibleImageViews.removeLast()
178 | }
179 | }
180 | }
181 |
182 | // remove images that have fallen over the left edge
183 |
184 | shouldRemove = true
185 |
186 | while shouldRemove
187 | {
188 | shouldRemove = false
189 |
190 | if let iv = visibleImageViews.first
191 | {
192 | if CGRectGetMaxX(iv.frame) < minVisX
193 | {
194 | imageViews.insert(iv, atIndex: 0)
195 | iv.removeFromSuperview()
196 | shouldRemove = true
197 | visibleImageViews.removeAtIndex(0)
198 | }
199 | }
200 | }
201 |
202 | }
203 |
204 | }
205 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay/Base.lproj/Main.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
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 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
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 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 |
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 |
--------------------------------------------------------------------------------
/ScrollViewPlay/ScrollViewPlay.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | E8717A8F1B492D2B006DC5EF /* NestedScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8717A8E1B492D2B006DC5EF /* NestedScrollViewController.swift */; };
11 | E8C1B5841B454323004C787B /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C1B5831B454323004C787B /* AppDelegate.swift */; };
12 | E8C1B5891B454323004C787B /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = E8C1B5871B454323004C787B /* Main.storyboard */; };
13 | E8C1B58B1B454323004C787B /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = E8C1B58A1B454323004C787B /* Images.xcassets */; };
14 | E8C1B58E1B454323004C787B /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = E8C1B58C1B454323004C787B /* LaunchScreen.xib */; };
15 | E8C1B59A1B454323004C787B /* ScrollViewPlayTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C1B5991B454323004C787B /* ScrollViewPlayTests.swift */; };
16 | E8C1B5A41B45436D004C787B /* TableViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C1B5A31B45436D004C787B /* TableViewController.swift */; };
17 | E8C1B5AA1B454576004C787B /* HeaderZoomViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C1B5A91B454576004C787B /* HeaderZoomViewController.swift */; };
18 | E8C1B5AD1B4546FB004C787B /* HeaderZoomScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C1B5AC1B4546FB004C787B /* HeaderZoomScrollView.swift */; };
19 | E8C1B5AF1B457487004C787B /* InfiniteScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C1B5AE1B457487004C787B /* InfiniteScrollView.swift */; };
20 | E8C1B5B11B457CB7004C787B /* InfiniteScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8C1B5B01B457CB7004C787B /* InfiniteScrollViewController.swift */; };
21 | E8D8C6C31B495A020023884D /* DynamicCollectionLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D8C6C21B495A020023884D /* DynamicCollectionLayout.swift */; };
22 | E8D8C6C51B49AC290023884D /* ScrollTouchViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D8C6C41B49AC290023884D /* ScrollTouchViewController.swift */; };
23 | E8D8C6C71B49AC390023884D /* DotView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D8C6C61B49AC390023884D /* DotView.swift */; };
24 | E8D8C6C91B49B9A20023884D /* OverlayScrollView.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D8C6C81B49B9A20023884D /* OverlayScrollView.swift */; };
25 | E8D8C6CB1B49C3960023884D /* TouchDelayRecognizer.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8D8C6CA1B49C3960023884D /* TouchDelayRecognizer.swift */; };
26 | E8F1C11D1B492BB70074B1B8 /* ScrollableCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8F1C11C1B492BB70074B1B8 /* ScrollableCell.swift */; };
27 | /* End PBXBuildFile section */
28 |
29 | /* Begin PBXContainerItemProxy section */
30 | E8C1B5941B454323004C787B /* PBXContainerItemProxy */ = {
31 | isa = PBXContainerItemProxy;
32 | containerPortal = E8C1B5761B454323004C787B /* Project object */;
33 | proxyType = 1;
34 | remoteGlobalIDString = E8C1B57D1B454323004C787B;
35 | remoteInfo = ScrollViewPlay;
36 | };
37 | /* End PBXContainerItemProxy section */
38 |
39 | /* Begin PBXFileReference section */
40 | E8717A8E1B492D2B006DC5EF /* NestedScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NestedScrollViewController.swift; sourceTree = ""; };
41 | E8C1B57E1B454323004C787B /* ScrollViewPlay.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ScrollViewPlay.app; sourceTree = BUILT_PRODUCTS_DIR; };
42 | E8C1B5821B454323004C787B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
43 | E8C1B5831B454323004C787B /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
44 | E8C1B5881B454323004C787B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
45 | E8C1B58A1B454323004C787B /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Images.xcassets; sourceTree = ""; };
46 | E8C1B58D1B454323004C787B /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; };
47 | E8C1B5931B454323004C787B /* ScrollViewPlayTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = ScrollViewPlayTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
48 | E8C1B5981B454323004C787B /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
49 | E8C1B5991B454323004C787B /* ScrollViewPlayTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ScrollViewPlayTests.swift; sourceTree = ""; };
50 | E8C1B5A31B45436D004C787B /* TableViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TableViewController.swift; sourceTree = ""; };
51 | E8C1B5A91B454576004C787B /* HeaderZoomViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderZoomViewController.swift; sourceTree = ""; };
52 | E8C1B5AC1B4546FB004C787B /* HeaderZoomScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HeaderZoomScrollView.swift; sourceTree = ""; };
53 | E8C1B5AE1B457487004C787B /* InfiniteScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InfiniteScrollView.swift; sourceTree = ""; };
54 | E8C1B5B01B457CB7004C787B /* InfiniteScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = InfiniteScrollViewController.swift; sourceTree = ""; };
55 | E8D8C6C21B495A020023884D /* DynamicCollectionLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DynamicCollectionLayout.swift; sourceTree = ""; };
56 | E8D8C6C41B49AC290023884D /* ScrollTouchViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollTouchViewController.swift; sourceTree = ""; };
57 | E8D8C6C61B49AC390023884D /* DotView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = DotView.swift; sourceTree = ""; };
58 | E8D8C6C81B49B9A20023884D /* OverlayScrollView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = OverlayScrollView.swift; sourceTree = ""; };
59 | E8D8C6CA1B49C3960023884D /* TouchDelayRecognizer.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TouchDelayRecognizer.swift; sourceTree = ""; };
60 | E8D8C6CE1B49CCDE0023884D /* ScrollViewPlay-BridgingHeader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "ScrollViewPlay-BridgingHeader.h"; sourceTree = ""; };
61 | E8F1C11C1B492BB70074B1B8 /* ScrollableCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScrollableCell.swift; sourceTree = ""; };
62 | /* End PBXFileReference section */
63 |
64 | /* Begin PBXFrameworksBuildPhase section */
65 | E8C1B57B1B454323004C787B /* Frameworks */ = {
66 | isa = PBXFrameworksBuildPhase;
67 | buildActionMask = 2147483647;
68 | files = (
69 | );
70 | runOnlyForDeploymentPostprocessing = 0;
71 | };
72 | E8C1B5901B454323004C787B /* Frameworks */ = {
73 | isa = PBXFrameworksBuildPhase;
74 | buildActionMask = 2147483647;
75 | files = (
76 | );
77 | runOnlyForDeploymentPostprocessing = 0;
78 | };
79 | /* End PBXFrameworksBuildPhase section */
80 |
81 | /* Begin PBXGroup section */
82 | E8C1B5751B454323004C787B = {
83 | isa = PBXGroup;
84 | children = (
85 | E8C1B5801B454323004C787B /* ScrollViewPlay */,
86 | E8C1B5961B454323004C787B /* ScrollViewPlayTests */,
87 | E8C1B57F1B454323004C787B /* Products */,
88 | );
89 | sourceTree = "";
90 | };
91 | E8C1B57F1B454323004C787B /* Products */ = {
92 | isa = PBXGroup;
93 | children = (
94 | E8C1B57E1B454323004C787B /* ScrollViewPlay.app */,
95 | E8C1B5931B454323004C787B /* ScrollViewPlayTests.xctest */,
96 | );
97 | name = Products;
98 | sourceTree = "";
99 | };
100 | E8C1B5801B454323004C787B /* ScrollViewPlay */ = {
101 | isa = PBXGroup;
102 | children = (
103 | E8D8C6CE1B49CCDE0023884D /* ScrollViewPlay-BridgingHeader.h */,
104 | E8C1B5A71B45437F004C787B /* Controller */,
105 | E8C1B5A61B45437B004C787B /* View */,
106 | E8C1B5A51B454372004C787B /* Model */,
107 | E8C1B5811B454323004C787B /* Supporting Files */,
108 | );
109 | path = ScrollViewPlay;
110 | sourceTree = "";
111 | };
112 | E8C1B5811B454323004C787B /* Supporting Files */ = {
113 | isa = PBXGroup;
114 | children = (
115 | E8C1B5821B454323004C787B /* Info.plist */,
116 | );
117 | name = "Supporting Files";
118 | sourceTree = "";
119 | };
120 | E8C1B5961B454323004C787B /* ScrollViewPlayTests */ = {
121 | isa = PBXGroup;
122 | children = (
123 | E8C1B5991B454323004C787B /* ScrollViewPlayTests.swift */,
124 | E8C1B5971B454323004C787B /* Supporting Files */,
125 | );
126 | path = ScrollViewPlayTests;
127 | sourceTree = "";
128 | };
129 | E8C1B5971B454323004C787B /* Supporting Files */ = {
130 | isa = PBXGroup;
131 | children = (
132 | E8C1B5981B454323004C787B /* Info.plist */,
133 | );
134 | name = "Supporting Files";
135 | sourceTree = "";
136 | };
137 | E8C1B5A51B454372004C787B /* Model */ = {
138 | isa = PBXGroup;
139 | children = (
140 | E8C1B5831B454323004C787B /* AppDelegate.swift */,
141 | E8D8C6C21B495A020023884D /* DynamicCollectionLayout.swift */,
142 | E8D8C6CA1B49C3960023884D /* TouchDelayRecognizer.swift */,
143 | );
144 | name = Model;
145 | sourceTree = "";
146 | };
147 | E8C1B5A61B45437B004C787B /* View */ = {
148 | isa = PBXGroup;
149 | children = (
150 | E8D8C6C61B49AC390023884D /* DotView.swift */,
151 | E8F1C11B1B492B960074B1B8 /* Custom Cells */,
152 | E8C1B5AB1B4546C0004C787B /* Custom UIScrollviews */,
153 | E8C1B58C1B454323004C787B /* LaunchScreen.xib */,
154 | E8C1B58A1B454323004C787B /* Images.xcassets */,
155 | E8C1B5871B454323004C787B /* Main.storyboard */,
156 | );
157 | name = View;
158 | sourceTree = "";
159 | };
160 | E8C1B5A71B45437F004C787B /* Controller */ = {
161 | isa = PBXGroup;
162 | children = (
163 | E8C1B5A31B45436D004C787B /* TableViewController.swift */,
164 | E8C1B5A91B454576004C787B /* HeaderZoomViewController.swift */,
165 | E8C1B5B01B457CB7004C787B /* InfiniteScrollViewController.swift */,
166 | E8717A8E1B492D2B006DC5EF /* NestedScrollViewController.swift */,
167 | E8D8C6C41B49AC290023884D /* ScrollTouchViewController.swift */,
168 | );
169 | name = Controller;
170 | sourceTree = "";
171 | };
172 | E8C1B5AB1B4546C0004C787B /* Custom UIScrollviews */ = {
173 | isa = PBXGroup;
174 | children = (
175 | E8C1B5AC1B4546FB004C787B /* HeaderZoomScrollView.swift */,
176 | E8C1B5AE1B457487004C787B /* InfiniteScrollView.swift */,
177 | E8D8C6C81B49B9A20023884D /* OverlayScrollView.swift */,
178 | );
179 | name = "Custom UIScrollviews";
180 | sourceTree = "";
181 | };
182 | E8F1C11B1B492B960074B1B8 /* Custom Cells */ = {
183 | isa = PBXGroup;
184 | children = (
185 | E8F1C11C1B492BB70074B1B8 /* ScrollableCell.swift */,
186 | );
187 | name = "Custom Cells";
188 | sourceTree = "";
189 | };
190 | /* End PBXGroup section */
191 |
192 | /* Begin PBXNativeTarget section */
193 | E8C1B57D1B454323004C787B /* ScrollViewPlay */ = {
194 | isa = PBXNativeTarget;
195 | buildConfigurationList = E8C1B59D1B454323004C787B /* Build configuration list for PBXNativeTarget "ScrollViewPlay" */;
196 | buildPhases = (
197 | E8C1B57A1B454323004C787B /* Sources */,
198 | E8C1B57B1B454323004C787B /* Frameworks */,
199 | E8C1B57C1B454323004C787B /* Resources */,
200 | );
201 | buildRules = (
202 | );
203 | dependencies = (
204 | );
205 | name = ScrollViewPlay;
206 | productName = ScrollViewPlay;
207 | productReference = E8C1B57E1B454323004C787B /* ScrollViewPlay.app */;
208 | productType = "com.apple.product-type.application";
209 | };
210 | E8C1B5921B454323004C787B /* ScrollViewPlayTests */ = {
211 | isa = PBXNativeTarget;
212 | buildConfigurationList = E8C1B5A01B454323004C787B /* Build configuration list for PBXNativeTarget "ScrollViewPlayTests" */;
213 | buildPhases = (
214 | E8C1B58F1B454323004C787B /* Sources */,
215 | E8C1B5901B454323004C787B /* Frameworks */,
216 | E8C1B5911B454323004C787B /* Resources */,
217 | );
218 | buildRules = (
219 | );
220 | dependencies = (
221 | E8C1B5951B454323004C787B /* PBXTargetDependency */,
222 | );
223 | name = ScrollViewPlayTests;
224 | productName = ScrollViewPlayTests;
225 | productReference = E8C1B5931B454323004C787B /* ScrollViewPlayTests.xctest */;
226 | productType = "com.apple.product-type.bundle.unit-test";
227 | };
228 | /* End PBXNativeTarget section */
229 |
230 | /* Begin PBXProject section */
231 | E8C1B5761B454323004C787B /* Project object */ = {
232 | isa = PBXProject;
233 | attributes = {
234 | LastUpgradeCheck = 0630;
235 | ORGANIZATIONNAME = "Teodor Patras";
236 | TargetAttributes = {
237 | E8C1B57D1B454323004C787B = {
238 | CreatedOnToolsVersion = 6.3.2;
239 | };
240 | E8C1B5921B454323004C787B = {
241 | CreatedOnToolsVersion = 6.3.2;
242 | TestTargetID = E8C1B57D1B454323004C787B;
243 | };
244 | };
245 | };
246 | buildConfigurationList = E8C1B5791B454323004C787B /* Build configuration list for PBXProject "ScrollViewPlay" */;
247 | compatibilityVersion = "Xcode 3.2";
248 | developmentRegion = English;
249 | hasScannedForEncodings = 0;
250 | knownRegions = (
251 | en,
252 | Base,
253 | );
254 | mainGroup = E8C1B5751B454323004C787B;
255 | productRefGroup = E8C1B57F1B454323004C787B /* Products */;
256 | projectDirPath = "";
257 | projectRoot = "";
258 | targets = (
259 | E8C1B57D1B454323004C787B /* ScrollViewPlay */,
260 | E8C1B5921B454323004C787B /* ScrollViewPlayTests */,
261 | );
262 | };
263 | /* End PBXProject section */
264 |
265 | /* Begin PBXResourcesBuildPhase section */
266 | E8C1B57C1B454323004C787B /* Resources */ = {
267 | isa = PBXResourcesBuildPhase;
268 | buildActionMask = 2147483647;
269 | files = (
270 | E8C1B5891B454323004C787B /* Main.storyboard in Resources */,
271 | E8C1B58E1B454323004C787B /* LaunchScreen.xib in Resources */,
272 | E8C1B58B1B454323004C787B /* Images.xcassets in Resources */,
273 | );
274 | runOnlyForDeploymentPostprocessing = 0;
275 | };
276 | E8C1B5911B454323004C787B /* Resources */ = {
277 | isa = PBXResourcesBuildPhase;
278 | buildActionMask = 2147483647;
279 | files = (
280 | );
281 | runOnlyForDeploymentPostprocessing = 0;
282 | };
283 | /* End PBXResourcesBuildPhase section */
284 |
285 | /* Begin PBXSourcesBuildPhase section */
286 | E8C1B57A1B454323004C787B /* Sources */ = {
287 | isa = PBXSourcesBuildPhase;
288 | buildActionMask = 2147483647;
289 | files = (
290 | E8D8C6CB1B49C3960023884D /* TouchDelayRecognizer.swift in Sources */,
291 | E8717A8F1B492D2B006DC5EF /* NestedScrollViewController.swift in Sources */,
292 | E8C1B5AA1B454576004C787B /* HeaderZoomViewController.swift in Sources */,
293 | E8C1B5AD1B4546FB004C787B /* HeaderZoomScrollView.swift in Sources */,
294 | E8C1B5AF1B457487004C787B /* InfiniteScrollView.swift in Sources */,
295 | E8C1B5B11B457CB7004C787B /* InfiniteScrollViewController.swift in Sources */,
296 | E8D8C6C71B49AC390023884D /* DotView.swift in Sources */,
297 | E8D8C6C91B49B9A20023884D /* OverlayScrollView.swift in Sources */,
298 | E8D8C6C51B49AC290023884D /* ScrollTouchViewController.swift in Sources */,
299 | E8D8C6C31B495A020023884D /* DynamicCollectionLayout.swift in Sources */,
300 | E8C1B5841B454323004C787B /* AppDelegate.swift in Sources */,
301 | E8F1C11D1B492BB70074B1B8 /* ScrollableCell.swift in Sources */,
302 | E8C1B5A41B45436D004C787B /* TableViewController.swift in Sources */,
303 | );
304 | runOnlyForDeploymentPostprocessing = 0;
305 | };
306 | E8C1B58F1B454323004C787B /* Sources */ = {
307 | isa = PBXSourcesBuildPhase;
308 | buildActionMask = 2147483647;
309 | files = (
310 | E8C1B59A1B454323004C787B /* ScrollViewPlayTests.swift in Sources */,
311 | );
312 | runOnlyForDeploymentPostprocessing = 0;
313 | };
314 | /* End PBXSourcesBuildPhase section */
315 |
316 | /* Begin PBXTargetDependency section */
317 | E8C1B5951B454323004C787B /* PBXTargetDependency */ = {
318 | isa = PBXTargetDependency;
319 | target = E8C1B57D1B454323004C787B /* ScrollViewPlay */;
320 | targetProxy = E8C1B5941B454323004C787B /* PBXContainerItemProxy */;
321 | };
322 | /* End PBXTargetDependency section */
323 |
324 | /* Begin PBXVariantGroup section */
325 | E8C1B5871B454323004C787B /* Main.storyboard */ = {
326 | isa = PBXVariantGroup;
327 | children = (
328 | E8C1B5881B454323004C787B /* Base */,
329 | );
330 | name = Main.storyboard;
331 | sourceTree = "";
332 | };
333 | E8C1B58C1B454323004C787B /* LaunchScreen.xib */ = {
334 | isa = PBXVariantGroup;
335 | children = (
336 | E8C1B58D1B454323004C787B /* Base */,
337 | );
338 | name = LaunchScreen.xib;
339 | sourceTree = "";
340 | };
341 | /* End PBXVariantGroup section */
342 |
343 | /* Begin XCBuildConfiguration section */
344 | E8C1B59B1B454323004C787B /* Debug */ = {
345 | isa = XCBuildConfiguration;
346 | buildSettings = {
347 | ALWAYS_SEARCH_USER_PATHS = NO;
348 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
349 | CLANG_CXX_LIBRARY = "libc++";
350 | CLANG_ENABLE_MODULES = YES;
351 | CLANG_ENABLE_OBJC_ARC = YES;
352 | CLANG_WARN_BOOL_CONVERSION = YES;
353 | CLANG_WARN_CONSTANT_CONVERSION = YES;
354 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
355 | CLANG_WARN_EMPTY_BODY = YES;
356 | CLANG_WARN_ENUM_CONVERSION = YES;
357 | CLANG_WARN_INT_CONVERSION = YES;
358 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
359 | CLANG_WARN_UNREACHABLE_CODE = YES;
360 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
361 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
362 | COPY_PHASE_STRIP = NO;
363 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
364 | ENABLE_STRICT_OBJC_MSGSEND = YES;
365 | GCC_C_LANGUAGE_STANDARD = gnu99;
366 | GCC_DYNAMIC_NO_PIC = NO;
367 | GCC_NO_COMMON_BLOCKS = YES;
368 | GCC_OPTIMIZATION_LEVEL = 0;
369 | GCC_PREPROCESSOR_DEFINITIONS = (
370 | "DEBUG=1",
371 | "$(inherited)",
372 | );
373 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
374 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
375 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
376 | GCC_WARN_UNDECLARED_SELECTOR = YES;
377 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
378 | GCC_WARN_UNUSED_FUNCTION = YES;
379 | GCC_WARN_UNUSED_VARIABLE = YES;
380 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
381 | MTL_ENABLE_DEBUG_INFO = YES;
382 | ONLY_ACTIVE_ARCH = YES;
383 | SDKROOT = iphoneos;
384 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
385 | TARGETED_DEVICE_FAMILY = "1,2";
386 | };
387 | name = Debug;
388 | };
389 | E8C1B59C1B454323004C787B /* Release */ = {
390 | isa = XCBuildConfiguration;
391 | buildSettings = {
392 | ALWAYS_SEARCH_USER_PATHS = NO;
393 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
394 | CLANG_CXX_LIBRARY = "libc++";
395 | CLANG_ENABLE_MODULES = YES;
396 | CLANG_ENABLE_OBJC_ARC = YES;
397 | CLANG_WARN_BOOL_CONVERSION = YES;
398 | CLANG_WARN_CONSTANT_CONVERSION = YES;
399 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
400 | CLANG_WARN_EMPTY_BODY = YES;
401 | CLANG_WARN_ENUM_CONVERSION = YES;
402 | CLANG_WARN_INT_CONVERSION = YES;
403 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
404 | CLANG_WARN_UNREACHABLE_CODE = YES;
405 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
406 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
407 | COPY_PHASE_STRIP = NO;
408 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
409 | ENABLE_NS_ASSERTIONS = NO;
410 | ENABLE_STRICT_OBJC_MSGSEND = YES;
411 | GCC_C_LANGUAGE_STANDARD = gnu99;
412 | GCC_NO_COMMON_BLOCKS = YES;
413 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
414 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
415 | GCC_WARN_UNDECLARED_SELECTOR = YES;
416 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
417 | GCC_WARN_UNUSED_FUNCTION = YES;
418 | GCC_WARN_UNUSED_VARIABLE = YES;
419 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
420 | MTL_ENABLE_DEBUG_INFO = NO;
421 | SDKROOT = iphoneos;
422 | TARGETED_DEVICE_FAMILY = "1,2";
423 | VALIDATE_PRODUCT = YES;
424 | };
425 | name = Release;
426 | };
427 | E8C1B59E1B454323004C787B /* Debug */ = {
428 | isa = XCBuildConfiguration;
429 | buildSettings = {
430 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
431 | INFOPLIST_FILE = ScrollViewPlay/Info.plist;
432 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
433 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
434 | PRODUCT_NAME = "$(TARGET_NAME)";
435 | SWIFT_OBJC_BRIDGING_HEADER = "ScrollViewPlay-BridgingHeader.h";
436 | TARGETED_DEVICE_FAMILY = 1;
437 | };
438 | name = Debug;
439 | };
440 | E8C1B59F1B454323004C787B /* Release */ = {
441 | isa = XCBuildConfiguration;
442 | buildSettings = {
443 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
444 | INFOPLIST_FILE = ScrollViewPlay/Info.plist;
445 | IPHONEOS_DEPLOYMENT_TARGET = 8.3;
446 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
447 | PRODUCT_NAME = "$(TARGET_NAME)";
448 | SWIFT_OBJC_BRIDGING_HEADER = "ScrollViewPlay-BridgingHeader.h";
449 | TARGETED_DEVICE_FAMILY = 1;
450 | };
451 | name = Release;
452 | };
453 | E8C1B5A11B454323004C787B /* Debug */ = {
454 | isa = XCBuildConfiguration;
455 | buildSettings = {
456 | BUNDLE_LOADER = "$(TEST_HOST)";
457 | FRAMEWORK_SEARCH_PATHS = (
458 | "$(SDKROOT)/Developer/Library/Frameworks",
459 | "$(inherited)",
460 | );
461 | GCC_PREPROCESSOR_DEFINITIONS = (
462 | "DEBUG=1",
463 | "$(inherited)",
464 | );
465 | INFOPLIST_FILE = ScrollViewPlayTests/Info.plist;
466 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
467 | PRODUCT_NAME = "$(TARGET_NAME)";
468 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ScrollViewPlay.app/ScrollViewPlay";
469 | };
470 | name = Debug;
471 | };
472 | E8C1B5A21B454323004C787B /* Release */ = {
473 | isa = XCBuildConfiguration;
474 | buildSettings = {
475 | BUNDLE_LOADER = "$(TEST_HOST)";
476 | FRAMEWORK_SEARCH_PATHS = (
477 | "$(SDKROOT)/Developer/Library/Frameworks",
478 | "$(inherited)",
479 | );
480 | INFOPLIST_FILE = ScrollViewPlayTests/Info.plist;
481 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
482 | PRODUCT_NAME = "$(TARGET_NAME)";
483 | TEST_HOST = "$(BUILT_PRODUCTS_DIR)/ScrollViewPlay.app/ScrollViewPlay";
484 | };
485 | name = Release;
486 | };
487 | /* End XCBuildConfiguration section */
488 |
489 | /* Begin XCConfigurationList section */
490 | E8C1B5791B454323004C787B /* Build configuration list for PBXProject "ScrollViewPlay" */ = {
491 | isa = XCConfigurationList;
492 | buildConfigurations = (
493 | E8C1B59B1B454323004C787B /* Debug */,
494 | E8C1B59C1B454323004C787B /* Release */,
495 | );
496 | defaultConfigurationIsVisible = 0;
497 | defaultConfigurationName = Release;
498 | };
499 | E8C1B59D1B454323004C787B /* Build configuration list for PBXNativeTarget "ScrollViewPlay" */ = {
500 | isa = XCConfigurationList;
501 | buildConfigurations = (
502 | E8C1B59E1B454323004C787B /* Debug */,
503 | E8C1B59F1B454323004C787B /* Release */,
504 | );
505 | defaultConfigurationIsVisible = 0;
506 | defaultConfigurationName = Release;
507 | };
508 | E8C1B5A01B454323004C787B /* Build configuration list for PBXNativeTarget "ScrollViewPlayTests" */ = {
509 | isa = XCConfigurationList;
510 | buildConfigurations = (
511 | E8C1B5A11B454323004C787B /* Debug */,
512 | E8C1B5A21B454323004C787B /* Release */,
513 | );
514 | defaultConfigurationIsVisible = 0;
515 | defaultConfigurationName = Release;
516 | };
517 | /* End XCConfigurationList section */
518 | };
519 | rootObject = E8C1B5761B454323004C787B /* Project object */;
520 | }
521 |
--------------------------------------------------------------------------------