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 | |
fileprivate var IMAGE_CACHE = NSCache<NSString, UIImage>() | |
class ImageViewSpinner:UIImageView { | |
private var loadingIndicator = UIActivityIndicatorView() | |
var url:String = "" { | |
didSet { |
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 | |
@IBDesignable | |
class InspectableUIView: UIView { | |
@IBInspectable var cornerRadius: CGFloat = 0 { | |
didSet { | |
// layer.cornerRadius = CGRectGetHeight(self.bounds) / 2.0//Circle | |
layer.cornerRadius = cornerRadius | |
// layer.masksToBounds = cornerRadius > 0 |
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 | |
enum Crud:String { | |
case get = "GET" | |
case post = "POST" | |
case put = "PUT" | |
case delete = "DELETE" | |
} | |
open class APIResponse: CustomDebugStringConvertible { |
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
class TemplateDebugClass: CustomDebugStringConvertible { | |
public var title: String = "" | |
public init(data: [String:AnyObject]) { | |
self.title = (data["title"] as? String ?? "").trim() | |
} | |
public var debugDescription: String { | |
return "<title=\(self.title);>" | |
} |
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 | |
public class GCD { | |
public class func mainThread(block:@escaping () -> Void) { | |
DispatchQueue.main.async {block()} | |
} | |
public class func mainThreadDelayed(delay: TimeInterval, block:@escaping () -> Void) { | |
DispatchQueue.main.asyncAfter(deadline: .now() + delay) {block()} |
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 | |
public extension String { | |
public func trim() -> String { | |
return self.trimmingCharacters(in: CharacterSet.whitespaces) | |
} | |
func isURL() -> Bool { | |
//swiftlint:disable:next custom_rules | |
return self.lowercased().hasPrefix("http://") || self.lowercased().hasPrefix("https://") |
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
<key>NSAppTransportSecurity</key> | |
<dict> | |
<!--Include to allow all connections (DANGER)--> | |
<key>NSAllowsArbitraryLoads</key> | |
<true/> | |
</dict> |
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 | |
//------------------------------------------------------------------------------- | |
//MARK: - API | |
class API { | |
enum Method:String { | |
case get = "GET" | |
case post = "POST" |
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 UIImageView { | |
func loadImage(url: String, completed: @escaping (_ success: Bool) -> Void) { | |
API.get(url: url) { (code, object) in | |
if let img = object as? UIImage { | |
self.image = img | |
completed(true) | |
} else { | |
completed(false) |
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 | |
class MaterialView: UIView { | |
override func awakeFromNib() { | |
layer.cornerRadius = 2.0 | |
layer.shadowColor = UIColor(red: 157.0 / 255.0, green: 157.0 / 255.0, blue: 157.0 / 255.0, alpha: 0.5).cgColor | |
layer.shadowOpacity = 0.8 | |
layer.shadowRadius = 5.0 | |
layer.shadowOffset = CGSize(width: 0.0, height: 2.0) |
OlderNewer