This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
class SwipeViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UIScrollViewDelegate { | |
@IBOutlet var imageViewBackground: UIImageView! | |
@IBOutlet var collectionView: UICollectionView! | |
let arraySampleContent:[[String: String]] = [ | |
["text": "content 1", "image_name": "img_background_1"], | |
["text": "content 2", "image_name": "img_background_2"], |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func gestureTap(_ sender: UITapGestureRecognizer) { | |
self.hideMenu() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func gesturePan(_ sender: UIPanGestureRecognizer) { | |
// retrieve the current state of the gesture | |
if sender.state == UIGestureRecognizerState.began { | |
// no need to do anything | |
} else if sender.state == UIGestureRecognizerState.changed { | |
// retrieve the amount viewMenu has been dragged | |
let translationX = sender.translation(in: sender.view).x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@IBAction func gestureScreenEdgePan(_ sender: UIScreenEdgePanGestureRecognizer) { | |
// retrieve the current state of the gesture | |
if sender.state == UIGestureRecognizerState.began { | |
// if the user has just started dragging, make sure view for dimming effect is hidden well | |
viewBlack.isHidden = false | |
viewBlack.alpha = 0 | |
} else if (sender.state == UIGestureRecognizerState.changed) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// define a variable to store initial touch position | |
var initialTouchPoint: CGPoint = CGPoint(x: 0,y: 0) | |
@IBAction func panGestureRecognizerHandler(_ sender: UIPanGestureRecognizer) { | |
let touchPoint = sender.location(in: self.view?.window) | |
if sender.state == UIGestureRecognizerState.began { | |
initialTouchPoint = touchPoint | |
} else if sender.state == UIGestureRecognizerState.changed { | |
if touchPoint.y - initialTouchPoint.y > 0 { |