Skip to content

Instantly share code, notes, and snippets.

View BrentMifsud's full-sized avatar

Brent Mifsud BrentMifsud

View GitHub Profile
@BrentMifsud
BrentMifsud / MKCoordinateRegion+OffsetZoomHelpers.swift
Last active February 24, 2021 23:25
Helper Extensions for zooming Annotations and Overlays with an offset from the center of the map.
extension MKCoordinateRegion {
/// Initialize a `MKCoordinateRegion` from a set of `MKAnnotations`
/// - Parameter annotations: Annotations
init(for annotations: [MKAnnotation]) {
var minLat: CLLocationDegrees = 90.0
var maxLat: CLLocationDegrees = -90.0
var minLon: CLLocationDegrees = 180.0
var maxLon: CLLocationDegrees = -180.0
for annotation in annotations {
@BrentMifsud
BrentMifsud / HTTPStatusCode.swift
Last active February 21, 2021 07:35 — forked from ollieatkinson/HTTPStatusCode.swift
HTTP status codes as a Swift enum.
/// This is a list of Hypertext Transfer Protocol (HTTP) response status codes.
/// It includes codes from IETF internet standards, other IETF RFCs, other specifications, and some additional commonly used codes.
/// The first digit of the status code specifies one of five classes of response; an HTTP client must recognise these five classes at a minimum.
#if canImport(Foundation)
import Foundation
#else
import FoundationNetworking
#endif
@BrentMifsud
BrentMifsud / Image+Data.swift
Last active July 14, 2024 12:50
SwiftUI Image from data
import Foundation
import SwiftUI
#if canImport(UIKit)
import UIKit
#elseif canImport(AppKit)
import AppKit
#endif
extension Image {
/// Initializes a SwiftUI `Image` from data.
import UIKit
extension UITabBarController {
/// Extends the size of the `UITabBarController` view frame, pushing the tab bar controller off screen.
/// - Parameters:
/// - hidden: Hide or Show the `UITabBar`
/// - animated: Animate the change
func setTabBarHidden(_ hidden: Bool, animated: Bool) {
guard let vc = selectedViewController else { return }
guard tabBarHidden != hidden else { return }