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
// https://gist.github.com/JARinteractive/96cbba8f35dcd10bbb77 | |
import UIKit | |
extension CGSize { | |
public func centered(in rect: CGRect) -> CGRect { | |
let centeredPoint = CGPoint(x: rect.minX + abs(rect.width - width) / 2, y: rect.minY + abs(rect.height - height) / 2) | |
let size = CGSize(width: min(self.width, rect.width), height: min(self.height, rect.height)) | |
let point = CGPoint(x: max(centeredPoint.x, rect.minX), y: max(centeredPoint.y, rect.minY)) | |
return CGRect(origin: point, size: size) |
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 | |
import RxSwift | |
import RxSugar | |
protocol GenericTableCell: NSObjectProtocol { | |
typealias Class = Self | |
typealias ValueType | |
func populate(value: ValueType) | |
} |
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 Foundation | |
func waitUntil(_ checkSuccess: @autoclosure ()->Bool) { | |
return waitUntil(1.0, checkSuccess) | |
} | |
func waitUntil(_ timeout: Double, _ checkSuccess: @autoclosure ()->Bool) { | |
let startDate = NSDate() | |
var success = false | |
while !success && abs(startDate.timeIntervalSinceNow) < timeout { |
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 | |
private func delegateClassName() -> String? { | |
guard NSClassFromString("XCTestCase") == nil else { return nil } | |
return NSStringFromClass(AppDelegate) | |
} | |
UIApplicationMain(Process.argc, Process.unsafeArgv, nil, delegateClassName()) |
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
// #!Swift-1.1 | |
import Foundation | |
// MARK: - (1) classes | |
// Solution 1: | |
// - Use classes instead of struct | |
// Issue: Violate the concept of moving model to the value layer | |
// http://realm.io/news/andy-matuschak-controlling-complexity/ |
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 | |
@IBDesignable | |
class CustomTextField: UITextField { | |
var padding: UIEdgeInsets { | |
get { | |
return UIEdgeInsets(top: 0, left: paddingValue, bottom: 0, right: paddingValue) | |
} | |
} |
OlderNewer