Created
January 20, 2016 08:25
-
-
Save shu223/b00140c9c5c1d5c5696d to your computer and use it in GitHub Desktop.
Make the margins of UITextField editable in IB
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
@IBDesignable | |
class TextField: UITextField { | |
@IBInspectable var insetX: CGFloat = 0 | |
@IBInspectable var insetY: CGFloat = 0 | |
// placeholder position | |
override func textRectForBounds(bounds: CGRect) -> CGRect { | |
return CGRectInset(bounds , insetX , insetY) | |
} | |
// text position | |
override func editingRectForBounds(bounds: CGRect) -> CGRect { | |
return CGRectInset(bounds , insetX , insetY) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
http://stackoverflow.com/questions/2694411/text-inset-for-uitextfield