Skip to content

Instantly share code, notes, and snippets.

View crisbit's full-sized avatar

crisbit

  • Wonderland
View GitHub Profile
@crisbit
crisbit / ElapsedTime.swift
Created December 14, 2016 13:10
Calculate elapsed time in Swift
let start = Date()
print("Elapsed time: \(start.timeIntervalSinceNow) seconds")
@crisbit
crisbit / MYCustomView.swift
Last active December 22, 2021 08:35
Custom view which can be rendered by Interface Builder and a running iOS app alike. It uses autolayout for the subviews.
//
// MYCustomView.swift
// StatWidget
import UIKit
/**
Custom view which can be rendered by Interface Builder
and a running iOS app alike. It uses autolayout for the
@crisbit
crisbit / CreateCustomReusableView.swift
Last active December 22, 2021 08:34
How to make a custom reusable view in iOS
import Foundation
import UIKit
class CustomView: UIView {
convenience init() {
// Size doesn't matter if your widget is scalable
// and you are going to use Autolayout constraints
// on it
self.init(frame: CGRectZero)
@crisbit
crisbit / ViewWithDynamicWidthScrollingView.swift
Last active July 7, 2023 13:08
How to make a dynamic height scroll view programmatically in swift (using SnapKit)
import Foundation
class ViewWithDynamicWidthScrollingView: UIView {
convenience init() {
self.init(frame: CGRectMake(0, 0, UIScreen.mainScreen().bounds.width, UIScreen.mainScreen().bounds.height))
}
override init(frame: CGRect) {
super.init(frame: frame)