-
Notifications
You must be signed in to change notification settings - Fork 25
/
StackViewImagesViewController.swift
60 lines (47 loc) · 2.23 KB
/
StackViewImagesViewController.swift
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
//
// MultipleImagesViewController.swift
// Zoomy_Example
//
// Created by Menno on 13/04/2018.
// Copyright © 2018 CocoaPods. All rights reserved.
//
import UIKit
import Zoomy
class StackViewImagesViewController: UIViewController {
@IBOutlet weak var stackView: UIStackView!
@IBOutlet weak var scrollView: UIScrollView!
override func viewDidLoad() {
super.viewDidLoad()
removeStoryBoardImageView()
Images.trees.forEach { (image) in
let imageView = UIImageView(image: image)
imageView.addImageAspectRatioContraint()
self.stackView.addArrangedSubview(imageView)
addZoombehavior(for: imageView, settings: Settings.backgroundEnabledSettings .with(primaryBackgroundColor: UIColor.black.withAlphaComponent(0.8))
.with(secundaryBackgroundColor: .black)
.with(actionOnScrollBounceBottom: Action.dismissOverlay)
.with(actionOnTapOverlay: Action.dismissOverlay))
}
}
override func viewWillDisappear(_ animated: Bool) {
imageZoomControllers.values.forEach{ $0.dismissOverlay() }
}
func removeStoryBoardImageView() {
stackView.removeArrangedSubview(stackView.arrangedSubviews[0])
}
}
//MARK: - ZoomDelegate
extension StackViewImagesViewController: Zoomy.Delegate {
func didBeginPresentingOverlay(for imageView: UIImageView) {
// print("did begin presenting overlay for imageView: \(imageView)")
scrollView.isScrollEnabled = false
}
func didEndPresentingOverlay(for imageView: UIImageView) {
// print("did end presenting overlay for imageView: \(imageView)")
scrollView.isScrollEnabled = true
}
func contentStateDidChange(from fromState: ImageZoomControllerContentState, to toState: ImageZoomControllerContentState) {
// print("contentState did change from state: \(fromState) to state: \(toState)")
//You might want to show/hide statusbar here
}
}