Last active
December 12, 2015 03:08
-
-
Save piersadrian/4704045 to your computer and use it in GitHub Desktop.
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
UIButton *fetchButton = ^(NSString *labelText, CGFloat scalar, UIButtonType type, CGPoint origin) { | |
UIButton *button = [UIButton buttonWithType:type]; | |
UILabel *label = [[UILabel alloc] init]; | |
[label setText:labelText]; | |
CGSize buttonFrameSize = CGSizeMake([label.text sizeWithFont:label.font].width * scalar * 0.66f, | |
[label.text sizeWithFont:label.font].height * scalar); | |
[button setTitle:label.text forState:UIControlStateNormal]; | |
[button setTitleEdgeInsets:UIEdgeInsetsZero]; | |
[button setFrame:CGRectMake(origin.x - buttonFrameSize.width * 0.5, | |
origin.y - buttonFrameSize.height * 0.5, | |
buttonFrameSize.width, | |
buttonFrameSize.height)]; | |
return button; | |
}(@"Fetch Data", 2.0f, UIButtonTypeRoundedRect, | |
CGPointMake(self.frame.size.width / 2, self.frame.size.height / 2)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment