Created
August 2, 2013 22:27
-
-
Save colinta/6143990 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 InsetTextField < UITextField | |
attr :edgeInsets | |
def init | |
initWithFrame(CGRectZero) | |
end | |
def initWithFrame(frame) | |
super.tap do | |
@edgeInsets = [0, 0, 0, 0] | |
end | |
end | |
def awakeFromNib | |
@edgeInsets = [0, 0, 0, 0] | |
end | |
def edgeInsets=(val) | |
@edgeInsets = val | |
setNeedsDisplay | |
end | |
# placeholder position | |
def placeholderRectForBounds(bounds) | |
UIEdgeInsetsInsetRect(bounds, @edgeInsets) | |
end | |
# text position | |
def textRectForBounds(bounds) | |
UIEdgeInsetsInsetRect(bounds, @edgeInsets) | |
end | |
# editing position | |
def editingRectForBounds(bounds) | |
# super | |
UIEdgeInsetsInsetRect(bounds, @edgeInsets) | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment