This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIView { | |
/// Creates a bitmap-based graphics context with the specified options | |
/// | |
/// - Parameters: | |
/// - size: The size (measured in points) of the new bitmap context (view bounds' size used by default). This represents the size of the image returned by the UIGraphicsGetImageFromCurrentImageContext() function. To get the size of the bitmap in pixels, you must multiply the width and height values by the value in the scale parameter. | |
/// - opaque: A Boolean flag indicating whether the bitmap is opaque (default is `true`). If you know the bitmap is fully opaque, specify true to ignore the alpha channel and optimize the bitmap’s storage. Specifying false means that the bitmap must include an alpha channel to handle any partially transparent pixels. | |
/// - scale: The scale factor to apply to the bitmap. If you specify a value of 0.0 (default), the scale factor is set to the scale factor of the device’s main screen. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// | |
// CLLocation+Validate.swift | |
// CocoaExtensions | |
// | |
// Created by Abdurahim Jauzee on 21/12/2018. | |
// https://medium.com/@mizutori/make-it-even-better-than-nike-how-to-filter-locations-tracking-highly-accurate-location-in-774be045f8d6 | |
import Foundation | |
import CoreLocation |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private enum Field: Int { | |
case name, city, state, zip, country, phone | |
static var all: [Field] { | |
var fields: [Field] = [] | |
var raw = 0 | |
while let field = Field(rawValue: raw) { | |
fields.append(field) | |
raw += 1 | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
let stringWithEmoji = "النَّظافَةُ ضَرورِيَّةٌ في كُلِّ شَىءٍ 💧" | |
let rangeFromCharacters = NSMakeRange(0, stringWithEmoji.characters.count) | |
let rangeFromUtf16 = NSMakeRange(0, stringWithEmoji.utf16.count) | |
rangeFromCharacters.length // 26 | |
rangeFromUtf16.length // 77 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
extension UIEdgeInsets { | |
// let insets = UIEdgeInsets(15) | |
// —> UIEdgeInsets(top: 15, left: 15, bottom: 15, right: 15) | |
public init(_ padding: CGFloat) { | |
top = padding | |
bottom = padding | |
left = padding |