Created
January 19, 2015 19:45
-
-
Save TheKidCoder/b2488f1ba35a66f061ab to your computer and use it in GitHub Desktop.
Use tap with ObjC & Java ruby inter-op.
This file contains hidden or 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
def email_text_field | |
return @email_text_field if @email_text_field | |
@email_text_field = UITextField.alloc.initWithFrame([[0, 0], [225, 40]]) | |
@email_text_field.center = CGPointMake(self.view.frame.size.width / 2, (self.view.frame.size.height / 2) - 60) | |
@email_text_field.placeholder = "[email protected]" | |
@email_text_field.borderStyle = UITextBorderStyleRoundedRect | |
@email_text_field | |
end | |
#Smaller variable names... | |
def email_text_field | |
return @email_text_field if @email_text_field | |
@email_text_field = UITextField.alloc.initWithFrame([[0, 0], [225, 40]]) | |
@email_text_field.tap do |tf| | |
tf.center = CGPointMake(self.view.frame.size.width / 2, (self.view.frame.size.height / 2) - 60) | |
tf.placeholder = "[email protected]" | |
tf.borderStyle = UITextBorderStyleRoundedRect | |
end | |
@email_text_field | |
end | |
# Memoize all in one. | |
def email_text_field | |
return @email_text_field ||= UITextField.alloc.initWithFrame([[0, 0], [225, 40]]).tap do |tf| | |
tf.center = CGPointMake(self.view.frame.size.width / 2, (self.view.frame.size.height / 2) - 60) | |
tf.placeholder = "[email protected]" | |
tf.borderStyle = UITextBorderStyleRoundedRect | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment