├── .bundle
└── config
├── .gitignore
├── Gemfile
├── Gemfile.lock
├── LICENSE.md
├── README.md
├── Source
├── Extensions.swift
├── ScalingGridLayout.swift
├── ScalingLayoutProtocol.swift
└── ZoomCollectionView.swift
├── ZoomCollectionView.podspec
├── ZoomCollectionView.xcodeproj
└── project.pbxproj
├── ZoomCollectionView
├── AppDelegate.swift
├── Assets.xcassets
│ └── AppIcon.appiconset
│ │ └── Contents.json
├── Base.lproj
│ ├── LaunchScreen.storyboard
│ └── Main.storyboard
├── Info.plist
└── ViewController.swift
├── scale-default.png
└── scale-zoomed.png
/.bundle/config:
--------------------------------------------------------------------------------
1 | ---
2 | BUNDLE_PATH: "Vendor/Bundle"
3 | BUNDLE_DISABLE_SHARED_GEMS: "true"
4 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | .DS_Store
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | *.xcworkspace
13 | !default.xcworkspace
14 | xcuserdata
15 | profile
16 | *.moved-aside
17 | DerivedData
18 | .idea/
19 | # Pods - for those of you who use CocoaPods
20 | Pods
21 | Vendor/
22 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 | source "https://rubygems.org"
3 |
4 | # gem "rails"
5 |
6 | gem "cocoapods", "~> 1.0"
7 |
--------------------------------------------------------------------------------
/Gemfile.lock:
--------------------------------------------------------------------------------
1 | GEM
2 | remote: https://rubygems.org/
3 | specs:
4 | CFPropertyList (2.3.6)
5 | activesupport (4.2.10)
6 | i18n (~> 0.7)
7 | minitest (~> 5.1)
8 | thread_safe (~> 0.3, >= 0.3.4)
9 | tzinfo (~> 1.1)
10 | claide (1.0.2)
11 | cocoapods (1.3.1)
12 | activesupport (>= 4.0.2, < 5)
13 | claide (>= 1.0.2, < 2.0)
14 | cocoapods-core (= 1.3.1)
15 | cocoapods-deintegrate (>= 1.0.1, < 2.0)
16 | cocoapods-downloader (>= 1.1.3, < 2.0)
17 | cocoapods-plugins (>= 1.0.0, < 2.0)
18 | cocoapods-search (>= 1.0.0, < 2.0)
19 | cocoapods-stats (>= 1.0.0, < 2.0)
20 | cocoapods-trunk (>= 1.2.0, < 2.0)
21 | cocoapods-try (>= 1.1.0, < 2.0)
22 | colored2 (~> 3.1)
23 | escape (~> 0.0.4)
24 | fourflusher (~> 2.0.1)
25 | gh_inspector (~> 1.0)
26 | molinillo (~> 0.5.7)
27 | nap (~> 1.0)
28 | ruby-macho (~> 1.1)
29 | xcodeproj (>= 1.5.1, < 2.0)
30 | cocoapods-core (1.3.1)
31 | activesupport (>= 4.0.2, < 6)
32 | fuzzy_match (~> 2.0.4)
33 | nap (~> 1.0)
34 | cocoapods-deintegrate (1.0.1)
35 | cocoapods-downloader (1.1.3)
36 | cocoapods-plugins (1.0.0)
37 | nap
38 | cocoapods-search (1.0.0)
39 | cocoapods-stats (1.0.0)
40 | cocoapods-trunk (1.3.0)
41 | nap (>= 0.8, < 2.0)
42 | netrc (~> 0.11)
43 | cocoapods-try (1.1.0)
44 | colored2 (3.1.2)
45 | concurrent-ruby (1.0.5)
46 | escape (0.0.4)
47 | fourflusher (2.0.1)
48 | fuzzy_match (2.0.4)
49 | gh_inspector (1.0.3)
50 | i18n (0.9.1)
51 | concurrent-ruby (~> 1.0)
52 | minitest (5.10.3)
53 | molinillo (0.5.7)
54 | nanaimo (0.2.3)
55 | nap (1.1.0)
56 | netrc (0.11.0)
57 | ruby-macho (1.1.0)
58 | thread_safe (0.3.6)
59 | tzinfo (1.2.4)
60 | thread_safe (~> 0.1)
61 | xcodeproj (1.5.4)
62 | CFPropertyList (~> 2.3.3)
63 | claide (>= 1.0.2, < 2.0)
64 | colored2 (~> 3.1)
65 | nanaimo (~> 0.2.3)
66 |
67 | PLATFORMS
68 | ruby
69 |
70 | DEPENDENCIES
71 | cocoapods (~> 1.0)
72 |
73 | BUNDLED WITH
74 | 1.16.1
75 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 | Copyright (c) 2016 Johan Björk
3 |
4 | Permission is hereby granted, free of charge, to any person obtaining a copy of this
5 | software and associated documentation files (the "Software"), to deal in the Software
6 | without restriction, including without limitation the rights to use, copy, modify, merge,
7 | publish, distribute, sublicense, and/or sell copies of the Software, and to permit
8 | persons to whom the Software is furnished to do so, subject to the following conditions:
9 |
10 | The above copyright notice and this permission notice shall be included in all copies or
11 | substantial portions of the Software.
12 |
13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
14 | BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
16 | DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
18 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # ZoomCollectionView for iOS
2 | `UICollectionView` is great, but it is not zoomable (which is rather strange since
3 | it is inherits from `UIScrollView`). This project is an attempt to implement zooming
4 | using custom a `UICollectionViewLayout` which resizes itself to simulate the effect
5 | we know and love from `UIScrollView`.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 | ## Usage with cocoapods
15 | Add a pod requirement to your podfile:
16 | ```ruby
17 | target 'MyApp' do
18 | ...
19 | pod 'ZoomCollectionView', :git => 'https://github.com/helmutschneider/ZoomCollectionView.git'
20 | ...
21 | end
22 | ```
23 | Then instantiate the layout & view:
24 | ```swift
25 | class ViewController: UIViewController, UICollectionViewDataSource {
26 |
27 | static let cellId = "CellId"
28 | var zoomView: ZoomCollectionView?
29 |
30 | override func viewDidLoad() {
31 | super.viewDidLoad()
32 |
33 | let itemWidth = (self.view.frame.width - 20.0)/5.0
34 |
35 | // you can also implement your own scaling layout
36 | let layout = ScalingGridLayout(
37 | itemSize: CGSize(width: itemWidth, height: itemWidth),
38 | columns: 5,
39 | itemSpacing: 5.0,
40 | scale: 1.0
41 | )
42 |
43 | zoomView = ZoomCollectionView(
44 | frame: CGRect(origin: .zero, size: self.view.frame.size),
45 | layout: layout
46 | )
47 | zoomView!.collectionView.dataSource = self
48 | zoomView!.collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: ViewController.cellId)
49 | zoomView!.collectionView.backgroundColor = .white
50 |
51 | zoomView!.scrollView.minimumZoomScale = 1.0
52 | zoomView!.scrollView.zoomScale = 1.0
53 | zoomView!.scrollView.maximumZoomScale = 4.0
54 |
55 | view.addSubview(zoomView!)
56 | }
57 |
58 | ...UICollectionViewDataSource methods...
59 |
60 | }
61 | ```
62 | For a complete example, have a look at [ViewController.swift](ZoomCollectionView/ViewController.swift).
63 |
64 | ## How does it work?
65 | `ZoomCollectionView` is a container view that encapsulates three views:
66 | - A `UICollectionView` for the actual collection data
67 | - A `UIScrollView` for the zoom/scroll hooks
68 | - A dummy `UIView` that the scroll view uses for its zooming capabilities
69 |
70 | When the scroll view is zoomed or scrolled it forwards the content offset to
71 | the collection view and the scale factor to the `UICollectionViewLayout` which
72 | implements the following protocol:
73 |
74 | ```swift
75 | public protocol ScalingLayoutProtocol {
76 | func getScale() -> CGFloat
77 | func setScale(_ scale: CGFloat) -> Void
78 | func contentSizeForScale(_ scale: CGFloat) -> CGSize
79 | }
80 | ```
81 |
82 | How the layout recalculates its attributes is implementation specific but an example
83 | can be found in `ScalingGridLayout`.
84 |
85 | ## What works
86 | - Scrolling
87 | - Zooming
88 |
89 | ## What does not work
90 | - The bounce effect when `minimumZoomScale` or `maximumZoomScale` is reached. The reason for this is that the bounce effect does not trigger `scrollViewDidZoom` in the scroll view.
91 |
--------------------------------------------------------------------------------
/Source/Extensions.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import UIKit
3 |
4 | public extension CGSize {
5 | func scale(_ factor: CGFloat) -> CGSize {
6 | let transform = CGAffineTransform(scaleX: factor, y: factor)
7 | return self.applying(transform)
8 | }
9 | }
10 |
11 | public extension CGRect {
12 | func scale(_ factor: CGFloat) -> CGRect {
13 | let transform = CGAffineTransform(scaleX: factor, y: factor)
14 | return self.applying(transform)
15 | }
16 | }
17 |
18 | public extension UICollectionView {
19 |
20 | // credit to http://stackoverflow.com/questions/17704527/uicollectionview-not-removing-old-cells-after-scroll
21 | func getLingeringCells() -> [UICollectionViewCell] {
22 | let visibleRect = CGRect(origin: contentOffset, size: bounds.size)
23 | let visibleCells: [UIView] = self.visibleCells
24 |
25 | return subviews.filter { view in
26 | view is UICollectionViewCell &&
27 | visibleRect.intersects(view.frame) &&
28 | !visibleCells.contains(view)
29 | } as! [UICollectionViewCell]
30 | }
31 |
32 | func hideLingeringCells() {
33 | getLingeringCells().forEach { $0.isHidden = true }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/Source/ScalingGridLayout.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import UIKit
3 |
4 | open class ScalingGridLayout : UICollectionViewLayout, ScalingLayoutProtocol {
5 |
6 | open let itemSize: CGSize
7 | open let columns: CGFloat
8 | open let itemSpacing: CGFloat
9 |
10 | private var scale: CGFloat
11 | private var attributes: [UICollectionViewLayoutAttributes] = []
12 | private var contentSize: CGSize = .zero
13 |
14 | public init(itemSize: CGSize, columns: CGFloat, itemSpacing: CGFloat, scale: CGFloat) {
15 | self.itemSize = itemSize
16 | self.columns = columns
17 | self.itemSpacing = itemSpacing
18 | self.scale = scale
19 | super.init()
20 | }
21 |
22 | required public init?(coder aDecoder: NSCoder) {
23 | fatalError("init(coder:) has not been implemented")
24 | }
25 |
26 | override open var collectionViewContentSize: CGSize {
27 | return contentSize
28 | }
29 |
30 | open func contentSizeForScale(_ scale: CGFloat) -> CGSize {
31 | let itemCount = collectionView!.numberOfItems(inSection: 0)
32 | let rowCount = ceil(CGFloat(itemCount)/CGFloat(columns))
33 | let sz = CGSize(
34 | width: itemSize.width * columns + itemSpacing * (columns - 1),
35 | height: itemSize.height * rowCount + itemSpacing * (rowCount - 1)
36 | )
37 | return sz.scale(scale)
38 | }
39 |
40 | override open func prepare() {
41 | super.prepare()
42 | self.contentSize = contentSizeForScale(self.scale)
43 | let itemCount = self.collectionView!.numberOfItems(inSection: 0)
44 | let columnCount = self.columns
45 |
46 | attributes = (0.. [UICollectionViewLayoutAttributes]? {
61 | return attributes.filter { $0.frame.intersects(rect) }
62 | }
63 |
64 | override open func layoutAttributesForItem(at indexPath: IndexPath) -> UICollectionViewLayoutAttributes? {
65 | return attributes.first { $0.indexPath == indexPath }
66 | }
67 |
68 | open func setScale(_ scale: CGFloat) {
69 | self.scale = scale
70 | }
71 |
72 | open func getScale() -> CGFloat {
73 | return self.scale
74 | }
75 |
76 | }
77 |
--------------------------------------------------------------------------------
/Source/ScalingLayoutProtocol.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import CoreGraphics
3 |
4 | public protocol ScalingLayoutProtocol {
5 | func getScale() -> CGFloat
6 | func setScale(_ scale: CGFloat) -> Void
7 | func contentSizeForScale(_ scale: CGFloat) -> CGSize
8 | }
9 |
--------------------------------------------------------------------------------
/Source/ZoomCollectionView.swift:
--------------------------------------------------------------------------------
1 | import Foundation
2 | import UIKit
3 |
4 | open class ZoomCollectionView : UIView, UIScrollViewDelegate, UICollectionViewDelegate {
5 |
6 | open let collectionView: UICollectionView
7 | open let scrollView: UIScrollView
8 | open let dummyZoomView: UIView
9 | open let layout: UICollectionViewLayout
10 |
11 | public init(frame: CGRect, layout: UICollectionViewLayout) {
12 | collectionView = UICollectionView(frame: frame, collectionViewLayout: layout)
13 | scrollView = UIScrollView(frame: frame)
14 | dummyZoomView = UIView(frame: .zero)
15 |
16 | self.layout = layout
17 |
18 | super.init(frame: frame)
19 |
20 | // remove gesture recognizers from the collection
21 | // view and use the scroll views built-in instead.
22 | collectionView.gestureRecognizers?.forEach { collectionView.removeGestureRecognizer($0) }
23 |
24 | scrollView.delegate = self
25 | collectionView.delegate = self
26 |
27 | addSubview(collectionView)
28 | addSubview(scrollView)
29 | scrollView.addSubview(dummyZoomView)
30 |
31 | // bounce is currently not supported since the
32 | // animation does not call scrollViewDidZoom
33 | scrollView.bouncesZoom = false
34 |
35 | bringSubview(toFront: scrollView)
36 | }
37 |
38 | required public init?(coder aDecoder: NSCoder) {
39 | fatalError("init(coder:) has not been implemented")
40 | }
41 |
42 | open override func layoutSubviews() {
43 | super.layoutSubviews()
44 |
45 | if let layout = self.layout as? ScalingLayoutProtocol {
46 | let size = layout.contentSizeForScale(scrollView.zoomScale)
47 | scrollView.contentSize = size
48 | dummyZoomView.frame = CGRect(origin: .zero, size: size)
49 | }
50 | }
51 |
52 | open func viewForZooming(in scrollView: UIScrollView) -> UIView? {
53 | return dummyZoomView
54 | }
55 |
56 | open func scrollViewDidScroll(_ scrollView: UIScrollView) {
57 | collectionView.contentOffset = scrollView.contentOffset
58 | collectionView.hideLingeringCells()
59 | }
60 |
61 | open func scrollViewDidZoom(_ scrollView: UIScrollView) {
62 | if let layout = self.layout as? ScalingLayoutProtocol, layout.getScale() != scrollView.zoomScale {
63 | layout.setScale(scrollView.zoomScale)
64 | self.layout.invalidateLayout()
65 | collectionView.contentOffset = scrollView.contentOffset
66 | collectionView.hideLingeringCells()
67 | }
68 | }
69 |
70 | open func collectionView(_ collectionView: UICollectionView, willDisplay cell: UICollectionViewCell, forItemAt indexPath: IndexPath) {
71 | // cells might have been hidden by hideLingeringCells() so we must un-hide them.
72 | cell.isHidden = false
73 | }
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/ZoomCollectionView.podspec:
--------------------------------------------------------------------------------
1 | #
2 | # Be sure to run `pod spec lint ZoomCollectionView.podspec' to ensure this is a
3 | # valid spec and to remove all comments including this before submitting the spec.
4 | #
5 | # To learn more about Podspec attributes see http://docs.cocoapods.org/specification.html
6 | # To see working Podspecs in the CocoaPods repo see https://github.com/CocoaPods/Specs/
7 | #
8 |
9 | Pod::Spec.new do |s|
10 |
11 | # ――― Spec Metadata ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
12 | #
13 | # These will help people to find your library, and whilst it
14 | # can feel like a chore to fill in it's definitely to your advantage. The
15 | # summary should be tweet-length, and the description more in depth.
16 | #
17 |
18 | s.name = "ZoomCollectionView"
19 | s.version = "0.1"
20 | s.summary = "Zoomable collection view for iOS"
21 |
22 | # This description is used to generate tags and improve search results.
23 | # * Think: What does it do? Why did you write it? What is the focus?
24 | # * Try to keep it short, snappy and to the point.
25 | # * Write the description between the DESC delimiters below.
26 | # * Finally, don't worry about the indent, CocoaPods strips it!
27 | # s.description = <<-DESC
28 | # DESC
29 |
30 | s.homepage = "https://github.com/helmutschneider/ZoomCollectionView"
31 | # s.screenshots = "www.example.com/screenshots_1.gif", "www.example.com/screenshots_2.gif"
32 |
33 |
34 | # ――― Spec License ――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
35 | #
36 | # Licensing your code is important. See http://choosealicense.com for more info.
37 | # CocoaPods will detect a license file if there is a named LICENSE*
38 | # Popular ones are 'MIT', 'BSD' and 'Apache License, Version 2.0'.
39 | #
40 |
41 | s.license = "MIT"
42 | # s.license = { :type => "MIT", :file => "FILE_LICENSE" }
43 |
44 |
45 | # ――― Author Metadata ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
46 | #
47 | # Specify the authors of the library, with email addresses. Email addresses
48 | # of the authors are extracted from the SCM log. E.g. $ git log. CocoaPods also
49 | # accepts just a name if you'd rather not provide an email address.
50 | #
51 | # Specify a social_media_url where others can refer to, for example a twitter
52 | # profile URL.
53 | #
54 |
55 | s.author = { "Johan Björk" => "johanimon@gmail.com" }
56 | # Or just: s.author = "Johan Björk"
57 | # s.authors = { "Johan Björk" => "johanimon@gmail.com" }
58 | # s.social_media_url = "http://twitter.com/Johan Björk"
59 |
60 | # ――― Platform Specifics ――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
61 | #
62 | # If this Pod runs only on iOS or OS X, then specify the platform and
63 | # the deployment target. You can optionally include the target after the platform.
64 | #
65 |
66 | # s.platform = :ios
67 | s.platform = :ios, "8.0"
68 |
69 | # When using multiple platforms
70 | # s.ios.deployment_target = "5.0"
71 | # s.osx.deployment_target = "10.7"
72 | # s.watchos.deployment_target = "2.0"
73 | # s.tvos.deployment_target = "9.0"
74 |
75 |
76 | # ――― Source Location ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
77 | #
78 | # Specify the location from where the source should be retrieved.
79 | # Supports git, hg, bzr, svn and HTTP.
80 | #
81 |
82 | s.source = { :git => "https://github.com/helmutschneider/ZoomCollectionView.git" }
83 |
84 |
85 | # ――― Source Code ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
86 | #
87 | # CocoaPods is smart about how it includes source code. For source files
88 | # giving a folder will include any swift, h, m, mm, c & cpp files.
89 | # For header files it will include any header in the folder.
90 | # Not including the public_header_files will make all headers public.
91 | #
92 |
93 | s.source_files = "Source/**/*.{swift}"
94 | # s.exclude_files = "Classes/Exclude"
95 |
96 | # s.public_header_files = "Classes/**/*.h"
97 |
98 |
99 | # ――― Resources ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
100 | #
101 | # A list of resources included with the Pod. These are copied into the
102 | # target bundle with a build phase script. Anything else will be cleaned.
103 | # You can preserve files from being cleaned, please don't preserve
104 | # non-essential files like tests, examples and documentation.
105 | #
106 |
107 | # s.resource = "icon.png"
108 | # s.resources = "Resources/*.png"
109 |
110 | # s.preserve_paths = "FilesToSave", "MoreFilesToSave"
111 |
112 |
113 | # ――― Project Linking ―――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
114 | #
115 | # Link your library with frameworks, or libraries. Libraries do not include
116 | # the lib prefix of their name.
117 | #
118 |
119 | # s.framework = "SomeFramework"
120 | # s.frameworks = "SomeFramework", "AnotherFramework"
121 |
122 | # s.library = "iconv"
123 | # s.libraries = "iconv", "xml2"
124 |
125 |
126 | # ――― Project Settings ――――――――――――――――――――――――――――――――――――――――――――――――――――――――― #
127 | #
128 | # If your library depends on compiler flags you can set them in the xcconfig hash
129 | # where they will only apply to your library. If you depend on other Podspecs
130 | # you can include multiple dependencies to ensure it works.
131 |
132 | # s.requires_arc = true
133 |
134 | # s.xcconfig = { "HEADER_SEARCH_PATHS" => "$(SDKROOT)/usr/include/libxml2" }
135 | # s.dependency "JSONKit", "~> 1.4"
136 |
137 | end
138 |
--------------------------------------------------------------------------------
/ZoomCollectionView.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 047CBDC31DCFD00D0043E7B2 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047CBDC21DCFD00D0043E7B2 /* AppDelegate.swift */; };
11 | 047CBDC51DCFD00D0043E7B2 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 047CBDC41DCFD00D0043E7B2 /* ViewController.swift */; };
12 | 047CBDC81DCFD00D0043E7B2 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 047CBDC61DCFD00D0043E7B2 /* Main.storyboard */; };
13 | 047CBDCA1DCFD00D0043E7B2 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 047CBDC91DCFD00D0043E7B2 /* Assets.xcassets */; };
14 | 047CBDCD1DCFD00D0043E7B2 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 047CBDCB1DCFD00D0043E7B2 /* LaunchScreen.storyboard */; };
15 | 04804A911DD10DC1006B4DAE /* Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04804A8D1DD10DC1006B4DAE /* Extensions.swift */; };
16 | 04804A921DD10DC1006B4DAE /* ScalingGridLayout.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04804A8E1DD10DC1006B4DAE /* ScalingGridLayout.swift */; };
17 | 04804A931DD10DC1006B4DAE /* ScalingLayoutProtocol.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04804A8F1DD10DC1006B4DAE /* ScalingLayoutProtocol.swift */; };
18 | 04804A941DD10DC1006B4DAE /* ZoomCollectionView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 04804A901DD10DC1006B4DAE /* ZoomCollectionView.swift */; };
19 | /* End PBXBuildFile section */
20 |
21 | /* Begin PBXFileReference section */
22 | 047CBDBF1DCFD00D0043E7B2 /* ZoomCollectionView.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ZoomCollectionView.app; sourceTree = BUILT_PRODUCTS_DIR; };
23 | 047CBDC21DCFD00D0043E7B2 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
24 | 047CBDC41DCFD00D0043E7B2 /* ViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ViewController.swift; sourceTree = ""; };
25 | 047CBDC71DCFD00D0043E7B2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/Main.storyboard; sourceTree = ""; };
26 | 047CBDC91DCFD00D0043E7B2 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; };
27 | 047CBDCC1DCFD00D0043E7B2 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; };
28 | 047CBDCE1DCFD00D0043E7B2 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
29 | 04804A881DD101DE006B4DAE /* LICENSE.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = LICENSE.md; sourceTree = ""; };
30 | 04804A891DD101DE006B4DAE /* README.md */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = ""; };
31 | 04804A8D1DD10DC1006B4DAE /* Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Extensions.swift; sourceTree = ""; };
32 | 04804A8E1DD10DC1006B4DAE /* ScalingGridLayout.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScalingGridLayout.swift; sourceTree = ""; };
33 | 04804A8F1DD10DC1006B4DAE /* ScalingLayoutProtocol.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ScalingLayoutProtocol.swift; sourceTree = ""; };
34 | 04804A901DD10DC1006B4DAE /* ZoomCollectionView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ZoomCollectionView.swift; sourceTree = ""; };
35 | 04ED62B31DD60A7600C964B2 /* Gemfile */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = Gemfile; sourceTree = ""; };
36 | 04ED62B41DD60A7600C964B2 /* ZoomCollectionView.podspec */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = ZoomCollectionView.podspec; sourceTree = ""; };
37 | /* End PBXFileReference section */
38 |
39 | /* Begin PBXFrameworksBuildPhase section */
40 | 047CBDBC1DCFD00D0043E7B2 /* Frameworks */ = {
41 | isa = PBXFrameworksBuildPhase;
42 | buildActionMask = 2147483647;
43 | files = (
44 | );
45 | runOnlyForDeploymentPostprocessing = 0;
46 | };
47 | /* End PBXFrameworksBuildPhase section */
48 |
49 | /* Begin PBXGroup section */
50 | 047CBDB61DCFD00D0043E7B2 = {
51 | isa = PBXGroup;
52 | children = (
53 | 04ED62B31DD60A7600C964B2 /* Gemfile */,
54 | 04ED62B41DD60A7600C964B2 /* ZoomCollectionView.podspec */,
55 | 04804A881DD101DE006B4DAE /* LICENSE.md */,
56 | 04804A891DD101DE006B4DAE /* README.md */,
57 | 04804A8C1DD10DC1006B4DAE /* Source */,
58 | 047CBDC11DCFD00D0043E7B2 /* ZoomCollectionView */,
59 | 047CBDC01DCFD00D0043E7B2 /* Products */,
60 | );
61 | sourceTree = "";
62 | };
63 | 047CBDC01DCFD00D0043E7B2 /* Products */ = {
64 | isa = PBXGroup;
65 | children = (
66 | 047CBDBF1DCFD00D0043E7B2 /* ZoomCollectionView.app */,
67 | );
68 | name = Products;
69 | sourceTree = "";
70 | };
71 | 047CBDC11DCFD00D0043E7B2 /* ZoomCollectionView */ = {
72 | isa = PBXGroup;
73 | children = (
74 | 047CBDC21DCFD00D0043E7B2 /* AppDelegate.swift */,
75 | 047CBDC41DCFD00D0043E7B2 /* ViewController.swift */,
76 | 047CBDC61DCFD00D0043E7B2 /* Main.storyboard */,
77 | 047CBDC91DCFD00D0043E7B2 /* Assets.xcassets */,
78 | 047CBDCB1DCFD00D0043E7B2 /* LaunchScreen.storyboard */,
79 | 047CBDCE1DCFD00D0043E7B2 /* Info.plist */,
80 | );
81 | path = ZoomCollectionView;
82 | sourceTree = "";
83 | };
84 | 04804A8C1DD10DC1006B4DAE /* Source */ = {
85 | isa = PBXGroup;
86 | children = (
87 | 04804A8D1DD10DC1006B4DAE /* Extensions.swift */,
88 | 04804A8E1DD10DC1006B4DAE /* ScalingGridLayout.swift */,
89 | 04804A8F1DD10DC1006B4DAE /* ScalingLayoutProtocol.swift */,
90 | 04804A901DD10DC1006B4DAE /* ZoomCollectionView.swift */,
91 | );
92 | path = Source;
93 | sourceTree = "";
94 | };
95 | /* End PBXGroup section */
96 |
97 | /* Begin PBXNativeTarget section */
98 | 047CBDBE1DCFD00D0043E7B2 /* ZoomCollectionView */ = {
99 | isa = PBXNativeTarget;
100 | buildConfigurationList = 047CBDD11DCFD00D0043E7B2 /* Build configuration list for PBXNativeTarget "ZoomCollectionView" */;
101 | buildPhases = (
102 | 047CBDBB1DCFD00D0043E7B2 /* Sources */,
103 | 047CBDBC1DCFD00D0043E7B2 /* Frameworks */,
104 | 047CBDBD1DCFD00D0043E7B2 /* Resources */,
105 | );
106 | buildRules = (
107 | );
108 | dependencies = (
109 | );
110 | name = ZoomCollectionView;
111 | productName = ZoomCollectionView;
112 | productReference = 047CBDBF1DCFD00D0043E7B2 /* ZoomCollectionView.app */;
113 | productType = "com.apple.product-type.application";
114 | };
115 | /* End PBXNativeTarget section */
116 |
117 | /* Begin PBXProject section */
118 | 047CBDB71DCFD00D0043E7B2 /* Project object */ = {
119 | isa = PBXProject;
120 | attributes = {
121 | LastSwiftUpdateCheck = 0810;
122 | LastUpgradeCheck = 0920;
123 | ORGANIZATIONNAME = "Johan Björk";
124 | TargetAttributes = {
125 | 047CBDBE1DCFD00D0043E7B2 = {
126 | CreatedOnToolsVersion = 8.1;
127 | LastSwiftMigration = 0920;
128 | ProvisioningStyle = Automatic;
129 | };
130 | };
131 | };
132 | buildConfigurationList = 047CBDBA1DCFD00D0043E7B2 /* Build configuration list for PBXProject "ZoomCollectionView" */;
133 | compatibilityVersion = "Xcode 3.2";
134 | developmentRegion = English;
135 | hasScannedForEncodings = 0;
136 | knownRegions = (
137 | en,
138 | Base,
139 | );
140 | mainGroup = 047CBDB61DCFD00D0043E7B2;
141 | productRefGroup = 047CBDC01DCFD00D0043E7B2 /* Products */;
142 | projectDirPath = "";
143 | projectRoot = "";
144 | targets = (
145 | 047CBDBE1DCFD00D0043E7B2 /* ZoomCollectionView */,
146 | );
147 | };
148 | /* End PBXProject section */
149 |
150 | /* Begin PBXResourcesBuildPhase section */
151 | 047CBDBD1DCFD00D0043E7B2 /* Resources */ = {
152 | isa = PBXResourcesBuildPhase;
153 | buildActionMask = 2147483647;
154 | files = (
155 | 047CBDCD1DCFD00D0043E7B2 /* LaunchScreen.storyboard in Resources */,
156 | 047CBDCA1DCFD00D0043E7B2 /* Assets.xcassets in Resources */,
157 | 047CBDC81DCFD00D0043E7B2 /* Main.storyboard in Resources */,
158 | );
159 | runOnlyForDeploymentPostprocessing = 0;
160 | };
161 | /* End PBXResourcesBuildPhase section */
162 |
163 | /* Begin PBXSourcesBuildPhase section */
164 | 047CBDBB1DCFD00D0043E7B2 /* Sources */ = {
165 | isa = PBXSourcesBuildPhase;
166 | buildActionMask = 2147483647;
167 | files = (
168 | 047CBDC51DCFD00D0043E7B2 /* ViewController.swift in Sources */,
169 | 04804A941DD10DC1006B4DAE /* ZoomCollectionView.swift in Sources */,
170 | 04804A911DD10DC1006B4DAE /* Extensions.swift in Sources */,
171 | 047CBDC31DCFD00D0043E7B2 /* AppDelegate.swift in Sources */,
172 | 04804A931DD10DC1006B4DAE /* ScalingLayoutProtocol.swift in Sources */,
173 | 04804A921DD10DC1006B4DAE /* ScalingGridLayout.swift in Sources */,
174 | );
175 | runOnlyForDeploymentPostprocessing = 0;
176 | };
177 | /* End PBXSourcesBuildPhase section */
178 |
179 | /* Begin PBXVariantGroup section */
180 | 047CBDC61DCFD00D0043E7B2 /* Main.storyboard */ = {
181 | isa = PBXVariantGroup;
182 | children = (
183 | 047CBDC71DCFD00D0043E7B2 /* Base */,
184 | );
185 | name = Main.storyboard;
186 | sourceTree = "";
187 | };
188 | 047CBDCB1DCFD00D0043E7B2 /* LaunchScreen.storyboard */ = {
189 | isa = PBXVariantGroup;
190 | children = (
191 | 047CBDCC1DCFD00D0043E7B2 /* Base */,
192 | );
193 | name = LaunchScreen.storyboard;
194 | sourceTree = "";
195 | };
196 | /* End PBXVariantGroup section */
197 |
198 | /* Begin XCBuildConfiguration section */
199 | 047CBDCF1DCFD00D0043E7B2 /* Debug */ = {
200 | isa = XCBuildConfiguration;
201 | buildSettings = {
202 | ALWAYS_SEARCH_USER_PATHS = NO;
203 | CLANG_ANALYZER_NONNULL = YES;
204 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
205 | CLANG_CXX_LIBRARY = "libc++";
206 | CLANG_ENABLE_MODULES = YES;
207 | CLANG_ENABLE_OBJC_ARC = YES;
208 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
209 | CLANG_WARN_BOOL_CONVERSION = YES;
210 | CLANG_WARN_COMMA = YES;
211 | CLANG_WARN_CONSTANT_CONVERSION = YES;
212 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
213 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
214 | CLANG_WARN_EMPTY_BODY = YES;
215 | CLANG_WARN_ENUM_CONVERSION = YES;
216 | CLANG_WARN_INFINITE_RECURSION = YES;
217 | CLANG_WARN_INT_CONVERSION = YES;
218 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
219 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
220 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
221 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
222 | CLANG_WARN_STRICT_PROTOTYPES = YES;
223 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
224 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
225 | CLANG_WARN_UNREACHABLE_CODE = YES;
226 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
227 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
228 | COPY_PHASE_STRIP = NO;
229 | DEBUG_INFORMATION_FORMAT = dwarf;
230 | ENABLE_STRICT_OBJC_MSGSEND = YES;
231 | ENABLE_TESTABILITY = YES;
232 | GCC_C_LANGUAGE_STANDARD = gnu99;
233 | GCC_DYNAMIC_NO_PIC = NO;
234 | GCC_NO_COMMON_BLOCKS = YES;
235 | GCC_OPTIMIZATION_LEVEL = 0;
236 | GCC_PREPROCESSOR_DEFINITIONS = (
237 | "DEBUG=1",
238 | "$(inherited)",
239 | );
240 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
241 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
242 | GCC_WARN_UNDECLARED_SELECTOR = YES;
243 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
244 | GCC_WARN_UNUSED_FUNCTION = YES;
245 | GCC_WARN_UNUSED_VARIABLE = YES;
246 | IPHONEOS_DEPLOYMENT_TARGET = 10.1;
247 | MTL_ENABLE_DEBUG_INFO = YES;
248 | ONLY_ACTIVE_ARCH = YES;
249 | SDKROOT = iphoneos;
250 | SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
251 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
252 | };
253 | name = Debug;
254 | };
255 | 047CBDD01DCFD00D0043E7B2 /* Release */ = {
256 | isa = XCBuildConfiguration;
257 | buildSettings = {
258 | ALWAYS_SEARCH_USER_PATHS = NO;
259 | CLANG_ANALYZER_NONNULL = YES;
260 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
261 | CLANG_CXX_LIBRARY = "libc++";
262 | CLANG_ENABLE_MODULES = YES;
263 | CLANG_ENABLE_OBJC_ARC = YES;
264 | CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
265 | CLANG_WARN_BOOL_CONVERSION = YES;
266 | CLANG_WARN_COMMA = YES;
267 | CLANG_WARN_CONSTANT_CONVERSION = YES;
268 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
269 | CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
270 | CLANG_WARN_EMPTY_BODY = YES;
271 | CLANG_WARN_ENUM_CONVERSION = YES;
272 | CLANG_WARN_INFINITE_RECURSION = YES;
273 | CLANG_WARN_INT_CONVERSION = YES;
274 | CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
275 | CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
276 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
277 | CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
278 | CLANG_WARN_STRICT_PROTOTYPES = YES;
279 | CLANG_WARN_SUSPICIOUS_MOVE = YES;
280 | CLANG_WARN_SUSPICIOUS_MOVES = YES;
281 | CLANG_WARN_UNREACHABLE_CODE = YES;
282 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
283 | "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
284 | COPY_PHASE_STRIP = NO;
285 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
286 | ENABLE_NS_ASSERTIONS = NO;
287 | ENABLE_STRICT_OBJC_MSGSEND = YES;
288 | GCC_C_LANGUAGE_STANDARD = gnu99;
289 | GCC_NO_COMMON_BLOCKS = YES;
290 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
291 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
292 | GCC_WARN_UNDECLARED_SELECTOR = YES;
293 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
294 | GCC_WARN_UNUSED_FUNCTION = YES;
295 | GCC_WARN_UNUSED_VARIABLE = YES;
296 | IPHONEOS_DEPLOYMENT_TARGET = 10.1;
297 | MTL_ENABLE_DEBUG_INFO = NO;
298 | SDKROOT = iphoneos;
299 | SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
300 | VALIDATE_PRODUCT = YES;
301 | };
302 | name = Release;
303 | };
304 | 047CBDD21DCFD00D0043E7B2 /* Debug */ = {
305 | isa = XCBuildConfiguration;
306 | buildSettings = {
307 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
308 | DEVELOPMENT_TEAM = "";
309 | INFOPLIST_FILE = ZoomCollectionView/Info.plist;
310 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
311 | PRODUCT_BUNDLE_IDENTIFIER = helmut.ZoomCollectionView;
312 | PRODUCT_NAME = "$(TARGET_NAME)";
313 | SWIFT_VERSION = 4.0;
314 | };
315 | name = Debug;
316 | };
317 | 047CBDD31DCFD00D0043E7B2 /* Release */ = {
318 | isa = XCBuildConfiguration;
319 | buildSettings = {
320 | ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
321 | DEVELOPMENT_TEAM = "";
322 | INFOPLIST_FILE = ZoomCollectionView/Info.plist;
323 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
324 | PRODUCT_BUNDLE_IDENTIFIER = helmut.ZoomCollectionView;
325 | PRODUCT_NAME = "$(TARGET_NAME)";
326 | SWIFT_VERSION = 4.0;
327 | };
328 | name = Release;
329 | };
330 | /* End XCBuildConfiguration section */
331 |
332 | /* Begin XCConfigurationList section */
333 | 047CBDBA1DCFD00D0043E7B2 /* Build configuration list for PBXProject "ZoomCollectionView" */ = {
334 | isa = XCConfigurationList;
335 | buildConfigurations = (
336 | 047CBDCF1DCFD00D0043E7B2 /* Debug */,
337 | 047CBDD01DCFD00D0043E7B2 /* Release */,
338 | );
339 | defaultConfigurationIsVisible = 0;
340 | defaultConfigurationName = Release;
341 | };
342 | 047CBDD11DCFD00D0043E7B2 /* Build configuration list for PBXNativeTarget "ZoomCollectionView" */ = {
343 | isa = XCConfigurationList;
344 | buildConfigurations = (
345 | 047CBDD21DCFD00D0043E7B2 /* Debug */,
346 | 047CBDD31DCFD00D0043E7B2 /* Release */,
347 | );
348 | defaultConfigurationIsVisible = 0;
349 | defaultConfigurationName = Release;
350 | };
351 | /* End XCConfigurationList section */
352 | };
353 | rootObject = 047CBDB71DCFD00D0043E7B2 /* Project object */;
354 | }
355 |
--------------------------------------------------------------------------------
/ZoomCollectionView/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 |
3 | @UIApplicationMain
4 | class AppDelegate: UIResponder, UIApplicationDelegate {
5 |
6 | var window: UIWindow?
7 |
8 |
9 | func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
10 | // Override point for customization after application launch.
11 | return true
12 | }
13 |
14 | func applicationWillResignActive(_ application: UIApplication) {
15 | // 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.
16 | // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
17 | }
18 |
19 | func applicationDidEnterBackground(_ application: UIApplication) {
20 | // 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.
21 | // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
22 | }
23 |
24 | func applicationWillEnterForeground(_ application: UIApplication) {
25 | // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
26 | }
27 |
28 | func applicationDidBecomeActive(_ application: UIApplication) {
29 | // 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.
30 | }
31 |
32 | func applicationWillTerminate(_ application: UIApplication) {
33 | // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
34 | }
35 |
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/ZoomCollectionView/Assets.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "idiom" : "iphone",
5 | "size" : "20x20",
6 | "scale" : "2x"
7 | },
8 | {
9 | "idiom" : "iphone",
10 | "size" : "20x20",
11 | "scale" : "3x"
12 | },
13 | {
14 | "idiom" : "iphone",
15 | "size" : "29x29",
16 | "scale" : "2x"
17 | },
18 | {
19 | "idiom" : "iphone",
20 | "size" : "29x29",
21 | "scale" : "3x"
22 | },
23 | {
24 | "idiom" : "iphone",
25 | "size" : "40x40",
26 | "scale" : "2x"
27 | },
28 | {
29 | "idiom" : "iphone",
30 | "size" : "40x40",
31 | "scale" : "3x"
32 | },
33 | {
34 | "idiom" : "iphone",
35 | "size" : "60x60",
36 | "scale" : "2x"
37 | },
38 | {
39 | "idiom" : "iphone",
40 | "size" : "60x60",
41 | "scale" : "3x"
42 | }
43 | ],
44 | "info" : {
45 | "version" : 1,
46 | "author" : "xcode"
47 | }
48 | }
--------------------------------------------------------------------------------
/ZoomCollectionView/Base.lproj/LaunchScreen.storyboard:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/ZoomCollectionView/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 |
--------------------------------------------------------------------------------
/ZoomCollectionView/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIdentifier
10 | $(PRODUCT_BUNDLE_IDENTIFIER)
11 | CFBundleInfoDictionaryVersion
12 | 6.0
13 | CFBundleName
14 | $(PRODUCT_NAME)
15 | CFBundlePackageType
16 | APPL
17 | CFBundleShortVersionString
18 | 1.0
19 | CFBundleVersion
20 | 1
21 | LSRequiresIPhoneOS
22 |
23 | UILaunchStoryboardName
24 | LaunchScreen
25 | UIMainStoryboardFile
26 | Main
27 | UIRequiredDeviceCapabilities
28 |
29 | armv7
30 |
31 | UISupportedInterfaceOrientations
32 |
33 | UIInterfaceOrientationPortrait
34 | UIInterfaceOrientationLandscapeLeft
35 | UIInterfaceOrientationLandscapeRight
36 |
37 |
38 |
39 |
--------------------------------------------------------------------------------
/ZoomCollectionView/ViewController.swift:
--------------------------------------------------------------------------------
1 | import UIKit
2 |
3 | class ViewController: UIViewController, UICollectionViewDataSource {
4 |
5 | static let cellId = "CellId"
6 |
7 | var zoomView: ZoomCollectionView?
8 |
9 | override func viewDidLoad() {
10 | super.viewDidLoad()
11 |
12 | let itemWidth = (self.view.frame.width - 20.0)/5.0
13 | let layout = ScalingGridLayout(
14 | itemSize: CGSize(width: itemWidth, height: itemWidth),
15 | columns: 5,
16 | itemSpacing: 5.0,
17 | scale: 1.0
18 | )
19 |
20 | zoomView = ZoomCollectionView(
21 | frame: CGRect(origin: .zero, size: self.view.frame.size),
22 | layout: layout
23 | )
24 | zoomView!.collectionView.dataSource = self
25 | zoomView!.collectionView.register(UICollectionViewCell.self, forCellWithReuseIdentifier: ViewController.cellId)
26 | zoomView!.collectionView.backgroundColor = .white
27 |
28 | zoomView!.scrollView.minimumZoomScale = 1.0
29 | zoomView!.scrollView.zoomScale = 1.0
30 | zoomView!.scrollView.maximumZoomScale = 4.0
31 |
32 | view.addSubview(zoomView!)
33 | }
34 |
35 | override func didReceiveMemoryWarning() {
36 | super.didReceiveMemoryWarning()
37 | // Dispose of any resources that can be recreated.
38 | }
39 |
40 | func numberOfSections(in collectionView: UICollectionView) -> Int {
41 | return 1
42 | }
43 |
44 | func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int {
45 | return 100
46 | }
47 |
48 | func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
49 | let cell = collectionView.dequeueReusableCell(withReuseIdentifier: ViewController.cellId, for: indexPath)
50 | cell.backgroundColor = indexPath.row % 2 == 0 ? .orange : .blue
51 |
52 | return cell
53 | }
54 |
55 | }
56 |
57 |
--------------------------------------------------------------------------------
/scale-default.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helmutschneider/ZoomCollectionView/5d94f87cc58b6f7477d72845c4f7edeaac074eba/scale-default.png
--------------------------------------------------------------------------------
/scale-zoomed.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/helmutschneider/ZoomCollectionView/5d94f87cc58b6f7477d72845c4f7edeaac074eba/scale-zoomed.png
--------------------------------------------------------------------------------