This file contains 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 { | |
public var top: CGFloat { | |
get { | |
return self.frame.origin.y | |
} | |
set { | |
var frame = self.frame | |
frame.origin.y = newValue |
This file contains 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
/** | |
``` | |
// Encode a model with properties of type [String : Any] | |
var propertiesContainer = container.nestedContainer(keyedBy: DynamicKey.self, forKey: .properties) | |
if let properties = properties { | |
try propertiesContainer.encodeDynamicKeyValues(withDictionary: properties) | |
} | |
``` | |
inspired by https://gist.github.com/samwize/a82f29a1fb34091cd61fc06934568f82 | |
*/ |
This file contains 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 Foundation | |
// Copy from https://gist.github.com/loudmouth/332e8d89d8de2c1eaf81875cfcd22e24 | |
struct JSONCodingKeys: CodingKey { | |
var stringValue: String | |
init?(stringValue: String) { | |
self.stringValue = stringValue | |
} |
This file contains 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
// | |
// UIColor+hex.swift | |
// | |
// Created by Hisoka0917 on 2018/1/24. | |
// Copyright © 2018. All rights reserved. | |
// | |
import UIKit | |
import Foundation |
This file contains 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
extension NSObject { | |
private struct AssociatedKeys { | |
static var extensionProps: UInt8 = 0 | |
} | |
private var extensionProps: NSObject? { | |
get { | |
return objc_getAssociatedObject(self, &AssociatedKeys.extensionProps) as? NSObject | |
} | |
set { | |
objc_setAssociatedObject(self, &AssociatedKeys.extensionProps, newValue, objc_AssociationPolicy.OBJC_ASSOCIATION_RETAIN_NONATOMIC) |
This file contains 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
extension UIImage { | |
public convenience init?(color: UIColor, size: CGSize = CGSize(width: 1, height:1)) { | |
let rect = CGRect(origin: .zero, size: size) | |
UIGraphicsBeginImageContextWithOptions(rect.size, false, 1.0) | |
color.setFill() | |
UIRectFill(rect) | |
let image = UIGraphicsGetImageFromCurrentImageContext() | |
UIGraphicsEndImageContext() | |
guard let cgImage = image?.cgImage else { |
This file contains 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
extension Dictionary { | |
func urlQueryEncode() -> String { | |
return self | |
.map({ "\($0)=\($1)" }) | |
.joined(separator: "&") | |
.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)! | |
} | |
func queryParameters() -> String { | |
let parameterArray = self.map { (key, value) -> String in |
This file contains 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
extentsion String { | |
func SHA256() -> String { | |
if let stringData = self.data(using: .utf8) { | |
return self.hexStringFromData(input: digest(input: stringData as NSData)) | |
} else { | |
return self | |
} | |
} |
This file contains 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
<?xml version="1.0" encoding="UTF-8"?> | |
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> | |
<plist version="1.0"> | |
<dict> | |
<key>items</key> | |
<array> | |
<dict> | |
<key>assets</key> | |
<array> | |
<dict> |
OlderNewer