For example, you want to set 40% alpha transparence to #000000
(black color), you need to add 66
like this #66000000
.
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 PlaygroundSupport | |
import UIKit | |
class TableViewManager: NSObject, UITableViewDataSource, UITableViewDelegate { | |
weak var tableView: UITableView? | |
var strings = ["a", "b", "c", "d","e", "f", "g", "h","i", "j", "k", "dl","am", "bn", "co", "dp","aq", "br", "cs", "dt","au", "bv", "cw", "dx","ay", "bz", "caa", "dbb","acc", "bdd", "cee", "dff","agg", "bhh", "cii", "djj","akk", "bll", "cmm", "dnn","aoo", "bpp", "cqq", "zrr"] | |
func add(data: [String]) { |
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
// No Security | |
{ | |
"rules": { | |
".read": true, | |
".write": true | |
} | |
} |
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
@propertyWrapper | |
struct UserDefault<T> { | |
let key: String | |
let defaultValue: T | |
init(_ key: String, defaultValue: T) { | |
self.key = key | |
self.defaultValue = defaultValue | |
} |
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 MyView: UIView { | |
override init(frame: CGRect) { | |
super.init(frame: frame) | |
fromNib() | |
} | |
init() { | |
super.init(frame: CGRect.zero) | |
fromNib() | |
} |
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
private var __maxLengthsForTextField = [UITextField: Int]() | |
extension UITextField { | |
//https://stackoverflow.com/a/43099816/3110026 | |
@IBInspectable var maxLength: Int { | |
get { | |
guard let l = __maxLengthsForTextField[self] else { | |
return 150 // (global default-limit. or just, Int.max) | |
} | |
return l | |
} |
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
private var __maxLengthsForTextView = [UITextView: Int]() | |
private var kAssociationKeyMaxLengthTextView: Int = 0 | |
extension UITextView:UITextViewDelegate { | |
@IBInspectable var maxLength: Int { | |
get { | |
if let length = objc_getAssociatedObject(self, &kAssociationKeyMaxLengthTextView) as? Int { | |
return length | |
} else { | |
return Int.max |
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 UITableView { | |
func setEmptyMessage(_ message: String) { | |
let messageLabel = UILabel(frame: CGRect(x: 0, y: 0, width: self.bounds.size.width, height: self.bounds.size.height)) | |
messageLabel.text = message | |
messageLabel.textColor = .black | |
messageLabel.numberOfLines = 0; | |
messageLabel.textAlignment = .center; | |
messageLabel.font = UIFont.preferredFont(forTextStyle: .title3) | |
messageLabel.sizeToFit() |
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 UIView { | |
func addSubviewsUsingAutoLayout(_ views: UIView ...) { | |
subviews.forEach { | |
self.addSubview($0) | |
$0.translatesAutoresizingMaskIntoConstraints = false | |
} | |
} | |
} | |
@objc extension NSLayoutAnchor { |
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
@propertyWrapper | |
struct Trimmed { | |
private(set) var value: String? | |
var wrappedValue: String? { | |
get { | |
return value | |
} | |
set { | |
value = newValue?.trimmingCharacters(in: .whitespacesAndNewlines) | |
} |