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
{ | |
"users":[ { | |
"id": 1, | |
"name": "Leanne Graham", | |
"username": "Bret", | |
"email": "[email protected]", | |
"address": { | |
"street": "Kulas Light", | |
"suite": "Apt. 556", | |
"city": "Gwenborough", |
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
func scrollViewWillEndDragging(_ scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>) { | |
let pageWidth: Float = 214+22 // PagingWidth = CellWidth + Cell Space | |
let currentOffset: Float = Float(scrollView.contentOffset.x) | |
let targetOffset: Float = Float(targetContentOffset.pointee.x) | |
var newTargetOffset: Float = 0 | |
if targetOffset > currentOffset { | |
newTargetOffset = ceilf(currentOffset / pageWidth) * pageWidth | |
} | |
else { | |
newTargetOffset = floorf(currentOffset / pageWidth) * pageWidth |
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
// | |
// PickerCollectionViewFlowLayout.swift | |
// | |
// Created by Sachin Nautiyal on 21/06/17. | |
// Copyright © 2017 Sachin Nautiyal. All rights reserved. | |
// | |
import UIKit | |
class PickerCollectionViewFlowLayout: UICollectionViewFlowLayout { |