Skip to content

Instantly share code, notes, and snippets.

@shu223
Created January 20, 2016 08:25
Show Gist options
  • Save shu223/b00140c9c5c1d5c5696d to your computer and use it in GitHub Desktop.
Save shu223/b00140c9c5c1d5c5696d to your computer and use it in GitHub Desktop.
Make the margins of UITextField editable in IB
@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)
}
}
@shu223
Copy link
Author

shu223 commented Jan 20, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment