Skip to content

Instantly share code, notes, and snippets.

@kmikael
kmikael / AnimationControllerForPresentedController.swift
Last active May 11, 2017 15:25
[WIP] Creating a Custom Presentation Transition
// https://developer.apple.com/reference/uikit/uiviewcontrollertransitioningdelegate
class AnimationController: NSObject, UIViewControllerAnimatedTransitioning {
func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
return 0.2 // The duration of the animation
}
func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
// Since you are presenting a new view controller, you primarily need the new view controller
@kmikael
kmikael / HomeCollectionViewFlowLayout.swift
Last active March 10, 2021 09:31
Snapping, centering and automatically sizing flow layout
import UIKit
class HomeCollectionViewFlowLayout: UICollectionViewFlowLayout {
var isSetUp = false
override func prepare() {
super.prepare()
setUpIfNeeded()