Created
July 28, 2016 08:50
-
-
Save pofat/5e54b00603325a10e84aded00179ce68 to your computer and use it in GitHub Desktop.
Padding for UITextField
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
MyUITextField: UITextField { | |
// Whatever you like | |
let padding = UIEdgeInsets(top: 5, left: 5, bottom: 6, right: 6); | |
// Paddging for place holder | |
override func placeholderRectForBounds(bounds: CGRect) -> CGRect { | |
return UIEdgeInsetsInsetRect(bounds, padding) | |
} | |
// Padding for text | |
override func textRectForBounds(bounds: CGRect) -> CGRect { | |
return UIEdgeInsetsInsetRect(bounds, padding) | |
} | |
// Padding for text in editting mode | |
override func editingRectForBounds(bounds: CGRect) -> CGRect { | |
return UIEdgeInsetsInsetRect(bounds, padding) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment