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 MyView: UIView { | |
| @IBInspectable var borderColor: UIColor = UIColor.clear { | |
| didSet { | |
| layer.borderColor = borderColor.cgColor | |
| } | |
| } | |
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
| # This is Git's per-user configuration file. | |
| [user] | |
| # Please adapt and uncomment the following lines: | |
| name = x | |
| email = x | |
| [alias] | |
| co = checkout | |
| ci = commit | |
| st = status | |
| br = branch |
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 | |
| class Settings { | |
| static let shared = Settings() | |
| private let manager = UserDefaults.standard | |
| enum List: String { | |
| case notify | |
| case nightMode |
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 copyDatabaseIfNeeded() { | |
| let fileManager = FileManager.default | |
| guard let documentsUrl = fileManager.urls(for: .documentDirectory, in: .userDomainMask).first else { return } | |
| let finalDatabaseUrl = documentsUrl.appendingPathComponent("sample.db") | |
| do { | |
| if !fileManager.fileExists(atPath: finalDatabaseURL.path) { |
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 Int { | |
| func pluralize(one: String, two: String, more: String) -> String { | |
| let remainderOf10 = self % 10 | |
| let remainderOf100 = self % 100 | |
| if remainderOf10 == 1 && remainderOf10 != 11 { | |
| return one | |
| } |
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
| // Variant 1 | |
| extension UIViewController { | |
| static func instance<T: UIViewController>() -> T? { | |
| let name = String(describing: self) | |
| let storyboard = UIStoryboard(name: name, bundle: nil) | |
| let controller = storyboard.instantiateViewController(withIdentifier: name) | |
| return controller as? T | |
| } | |
| } |
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 MyLabel: UILabel { | |
| @IBInspectable var kerning: Float { | |
| get { | |
| let string = text ?? "" | |
| var range = NSMakeRange(0, string.count) | |
| guard let kern = attributedText?.attribute(.kern, at: 0, effectiveRange: &range), |
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 | |
| class ModalAnimationController: NSObject, UIViewControllerAnimatedTransitioning { | |
| func animateTransition(using transitionContext: UIViewControllerContextTransitioning) { | |
| fatalError("Abstract method") | |
| } | |
| let cornerRadius: CGFloat = 20 | |
| let offset: CGFloat = 60 |
OlderNewer