Skip to content

Instantly share code, notes, and snippets.

View bernardonigbinde's full-sized avatar

Bernard Onigbinde bernardonigbinde

View GitHub Profile
@bernardonigbinde
bernardonigbinde / UIView.swift
Created May 30, 2021 12:07
UIView extension - Auto Layout Helper
import UIKit
extension UIView {
func bottom(to view: UIView, offset: CGFloat = 0.0, usingSafeArea: Bool = false) {
constrain(bottomAnchor, to: usingSafeArea ? view.safeAreaLayoutGuide.bottomAnchor : view.bottomAnchor, of: view, offset: offset)
}
func topToBottom(of view: UIView, offset: CGFloat = 0.0, usingSafeArea: Bool = false) {
constrain(topAnchor, to: usingSafeArea ? view.safeAreaLayoutGuide.bottomAnchor : view.bottomAnchor, of: view, offset: offset)
}