Created
September 1, 2017 09:55
-
-
Save StanislavK/38583aa591b00e9729487de89b6ac596 to your computer and use it in GitHub Desktop.
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 CustomTextFieldWithPadding: UITextField { | |
let padding: CGFloat = 16 | |
private var paddingEdgeInsets: UIEdgeInsets { | |
return UIEdgeInsetsMake(0, padding, 0, padding) | |
} | |
required init?(coder aDecoder: NSCoder) { | |
super.init(coder: aDecoder) | |
} | |
override func textRect(forBounds bounds: CGRect) -> CGRect { | |
return UIEdgeInsetsInsetRect(bounds, paddingEdgeInsets) | |
} | |
override func editingRect(forBounds bounds: CGRect) -> CGRect { | |
return UIEdgeInsetsInsetRect(bounds, paddingEdgeInsets) | |
} | |
override func placeholderRect(forBounds bounds: CGRect) -> CGRect { | |
return UIEdgeInsetsInsetRect(bounds, paddingEdgeInsets) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment