Skip to content

Instantly share code, notes, and snippets.

View AntonTheDev's full-sized avatar

Anton AntonTheDev

View GitHub Profile
@AntonTheDev
AntonTheDev / BounceProofCollectionViewFlowLayout
Last active May 22, 2020 21:27
Slow Easing CollectionView and FlowLayout
import Foundation
import UIKit
class UIDirectionAbidingSlowingCollectionView : _UIDirectionAbidingCollectionView
{
override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout)
{
super.init(frame: frame, collectionViewLayout: layout)
let decelerationRate : CGFloat = 0.996
setValue(NSValue(cgPoint: CGPoint(x: decelerationRate, y: decelerationRate)), forKey: "_" + "decelerationFactor")
@AntonTheDev
AntonTheDev / gist:21481b57b1dce2341b88df1025caec51
Created September 18, 2018 15:57
XCode Hidden Speed Settings
Found these here... Seeems useful to have around every once in a blue moon (new machine)
https://stackoverflow.com/questions/37076718/increase-speed-to-xcode-builds-by-terminal-commands-only
There are more tips and tricks about how to decrease build timing.
Some of them are too old, other working only with simulator devices, other for example explain how to disable the code coverage support but always by make changes to the layout settings.
My purpose is to launch few effective terminal command lines or a good script (the last choice would be much better) so without changing Xcode layout settings, without adding libraries.., only by-terminal actions.
@AntonTheDev
AntonTheDev / StickyHeaderFlowLayout.swift
Created August 17, 2017 17:15
Sticky Header Layout (Swift 3)
class StickyHeaderFlowLayout : UICollectionViewFlowLayout {
override init() {
super.init()
minimumInteritemSpacing = 0.0
minimumLineSpacing = 0.0
sectionInset = UIEdgeInsets.zero
scrollDirection = .vertical
}
@AntonTheDev
AntonTheDev / ContenfulEntry+JSON.swift
Last active August 8, 2017 17:49
De-obfuscation of Contentful's model back to JSON
extension Entry {
fileprivate static let contenfulEntryIDKey = "id"
var jsonResponse : [String : Any] {
var entryFields = fields
entryFields[Entry.contenfulEntryIDKey] = id
for (key, value) in entryFields
{
@AntonTheDev
AntonTheDev / StackoverFlowExample
Created July 26, 2017 04:38
StackoverFlow Example
https://stackoverflow.com/questions/45250787/ios-correctly-adopting-a-view-into-an-already-visible-parent
extension UIViewController {
func adopChilViewController(_ childViewController: UIViewController) {
addChildViewController(childViewController)
view.addSubview(childViewController.view)
childViewController.didMove(toParentViewController: self)
}
}
@AntonTheDev
AntonTheDev / gist:ad109c1de51226de273785e8c38adcf9
Created July 18, 2017 17:11
Load JSON FileManager Extension
extension FileManager {
class func loadJSON(from file : String) -> Any? {
do {
if let file = Bundle.main.url(forResource: file, withExtension: "json") {
let data = try Data(contentsOf: file)
let json = try JSONSerialization.jsonObject(with: data, options: [])
if let dict = json as? [String: Any] {
return dict
} else if let array = json as? [Any] {
@AntonTheDev
AntonTheDev / UIDirectionAbidingCollectionView.swift
Created December 2, 2016 02:49
Scroll Direction Locking CollectionView, Relative to UICollectionViewFlowLayout (Proof of Concept)
import Foundation
import UIKit
class UIDirectionAbidingCollectionView : UICollectionView {
override init(frame: CGRect, collectionViewLayout layout: UICollectionViewLayout) {
super.init(frame: frame, collectionViewLayout: layout)
setupDelayRecognizer()
}
@AntonTheDev
AntonTheDev / Vertical Column Based Flow Layout
Last active November 11, 2016 17:13
Vertical Column Based Flow Layout
class SomeUIViewControllerExample: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
view.addSubview(collectionView)
collectionView.frame = view.bounds
}
lazy var collectionView : UICollectionView = {
[unowned self] in
@AntonTheDev
AntonTheDev / Sticky Header CollectionViewFlowLayout
Created September 22, 2016 21:22
Sticky Header CollectionViewFlowLayout
class NonBlinkyCollectionViewFlowLayout: UICollectionViewFlowLayout {
override init() {
super.init()
minimumInteritemSpacing = 0.0
minimumLineSpacing = 0.0
sectionInset = UIEdgeInsetsZero
scrollDirection = .Vertical
}
@AntonTheDev
AntonTheDev / Flip Card Animation New-Collectionviewcell
Last active September 1, 2023 10:15
StackOverflow Flip Card Animation New-Collectionviewcell
//
// ViewController.swift
// SwiftLayout
//
// Created by Anton Doudarev on 5/24/16.
// Copyright © 2016 Anton Doudarev. All rights reserved.
//
import UIKit