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
func supportsKeyboard(lang: String?) -> Bool { | |
guard let _lang = lang else { | |
return false | |
} | |
let predicates = [ | |
Predicate(format: "SELF == %@", "en"), | |
Predicate(format: "SELF like[cd] %@", "en-*") | |
] | |
for predicate in predicates { | |
if NSArray(arrayLiteral: _lang).filtered(using: predicate).count > 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
extension UISearchBar { | |
/** An easy way to set the magnifying glass color in interface builder | |
It is recommended to set this in interface Builder, | |
However if you want to do it programatically you can do it like this: | |
``` | |
let searchBar = UISearchBar() | |
searchBar.magnifyingGlassColor = UIColor.red | |
``` | |
*/ | |
@IBInspectable var magnifyingGlassColor: UIColor { |
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 UISearchBarMagnifyingGlass: NSObject { | |
@IBOutlet weak var searchBar: UISearchBar! { | |
didSet { | |
if let _color = color, let _searchBar = searchBar { | |
for i in _searchBar.subviews.first!.subviews { | |
if let textField = i as? UITextField, | |
let imageView = textField.leftView as? UIImageView, | |
let image = imageView.image | |
{ | |
let coloredImage = image.withRenderingMode(UIImageRenderingMode.alwaysTemplate) |
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 | |
protocol Initializer {} | |
extension Initializer { | |
func with(bootStrap: (inout Self) -> ()) -> Self { | |
var s = self | |
bootStrap(&s) | |
return s | |
} | |
} |
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
#if DEBUG | |
print("print debug value", x) | |
#endif |
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
ABC_OBJC=ABC=1 | |
ABC_SWIFT=ABC |
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
#if ABC | |
// Code between here that runs only when ABC exists | |
#endif |
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
// This is a conditional inclusion. | |
// It searches for a file called Captain.xcconfig that lives one file level up in relation to this file. | |
#include? "../Captain.xcconfig" |
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
enum PageNames: String { | |
case sc🖍search = "MySearch" | |
var page_name: String { | |
return String(describing: self).replacingOccurrences(of: "🖍", with: "/") | |
} | |
} | |
PageNames.sc🖍search.rawValue // "MySearch" |