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
// | |
// EShopLoadingView.swift | |
// EShopHelper | |
// | |
// Created by Jiang,Zhenhua on 2018/10/16. | |
// Copyright © 2018 Daubert. All rights reserved. | |
// | |
import UIKit |
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 Accelerate | |
import UIKit | |
extension UIImage { | |
private static let cache = NSCache<NSString, UIImage>() | |
func bluredImage(factor: CGFloat) -> UIImage? { | |
var blur = factor | |
if blur < 0 || blur > 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
// | |
// Optional.swift | |
// | |
// Created by Jiang,Zhenhua on 2018/11/25. | |
// | |
import Foundation | |
extension Optional { | |
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
// | |
// InfiniteTableView.swift | |
// EShopHelper | |
// | |
// Created by Jiang,Zhenhua on 2018/12/1. | |
// Copyright © 2018 Daubert. All rights reserved. | |
// | |
import UIKit |
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
// | |
// EHStreamSession.swift | |
// EShopHelper | |
// | |
// Created by Jiang,Zhenhua on 2018/12/3. | |
// Copyright © 2018 Daubert. All rights reserved. | |
// | |
import Foundation |
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
// | |
// UIApplication+Extensions.swift | |
// | |
// Created by Jiang,Zhenhua on 2018/12/17. | |
// Copyright © 2018 Daubert. All rights reserved. | |
// | |
import UIKit | |
import UserNotifications |
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
extension String { | |
var fourCharCode: FourCharCode? { | |
guard self.count == 4 else { | |
return nil | |
} | |
return self.utf16.reduce(0) { $0 << 8 + FourCharCode($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
extension DispatchTime: ExpressibleByIntegerLiteral { | |
public init(integerLiteral value: Int) { | |
self = DispatchTime.now() + .seconds(value) | |
} | |
} | |
extension DispatchTime: ExpressibleByFloatLiteral { | |
public init(floatLiteral value: Double) { | |
self = DispatchTime.now() + .milliseconds(Int(value * 1000)) | |
} |
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
func bridge<T : AnyObject>(obj : T) -> UnsafeRawPointer { | |
return UnsafeRawPointer(Unmanaged.passUnretained(obj).toOpaque()) | |
} | |
func bridge<T : AnyObject>(ptr : UnsafeRawPointer) -> T { | |
return Unmanaged<T>.fromOpaque(ptr).takeUnretainedValue() | |
} | |
func bridgeRetained<T : AnyObject>(obj : T) -> UnsafeRawPointer { | |
return UnsafeRawPointer(Unmanaged.passRetained(obj).toOpaque()) |
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
extension CALayer { | |
func applySketchShadow( | |
color: UIColor = .black, | |
alpha: Float = 0.5, | |
x: CGFloat = 0, | |
y: CGFloat = 2, | |
blur: CGFloat = 4, | |
spread: CGFloat = 0) | |
{ | |
shadowColor = color.cgColor |