Skip to content

Instantly share code, notes, and snippets.

View Nautiyalsachin's full-sized avatar

Sachin Nautiyal Nautiyalsachin

View GitHub Profile
@Nautiyalsachin
Nautiyalsachin / Users
Last active April 30, 2023 20:00
Test API Data For Users
{
"users":[ {
"id": 1,
"name": "Leanne Graham",
"username": "Bret",
"email": "Sincere@april.biz",
"address": {
"street": "Kulas Light",
"suite": "Apt. 556",
"city": "Gwenborough",
@Nautiyalsachin
Nautiyalsachin / CustomCollectionViewPaging.swift
Last active January 31, 2018 12:58
Used for providing custom paging for collection view.
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
@Nautiyalsachin
Nautiyalsachin / PickerCollectionViewFlowLayout.swift
Created June 29, 2017 08:15
PickerCollectionViewFlowLayout use for custom paging in your existing code, used for multiple cell in your collection view with custom paging. //don't forget to disable the paging.
//
// PickerCollectionViewFlowLayout.swift
//
// Created by Sachin Nautiyal on 21/06/17.
// Copyright © 2017 Sachin Nautiyal. All rights reserved.
//
import UIKit
class PickerCollectionViewFlowLayout: UICollectionViewFlowLayout {