Created
February 18, 2013 20:13
-
-
Save kerrishotts/4980294 to your computer and use it in GitHub Desktop.
UIBarButtonItem Utility: Quick & Dirty bar button item creation using Font Awesome, Text Attributes, and Background images.
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
You can use it like so: | |
#import "NSString+FontAwesome.h" | |
... | |
NSDictionary *faTextAttributes = @{ UITextAttributeFont : [UIFont fontWithName: kFontAwesomeFamilyName size: 22], | |
UITextAttributeTextColor : [UIColor whiteColor], | |
UITextAttributeTextShadowColor: [UIColor blackColor], | |
UITextAttributeTextShadowOffset: [NSValue valueWithCGSize: CGSizeMake(0,-1)] }; | |
NSDictionary *largeTextAttributes = @{ UITextAttributeFont : [UIFont fontWithName:@"Helvetica-Bold" size:20], | |
UITextAttributeTextColor : [UIColor whiteColor], | |
UITextAttributeTextShadowColor: [UIColor blackColor], | |
UITextAttributeTextShadowOffset: [NSValue valueWithCGSize: CGSizeMake(0,-1)] }; | |
UIImage *blankImage = [UIImage new]; | |
UIBarButtonItem *aMenuButton = [UIBarButtonItem barButtonItemUsingFontAwesomeIcon:@"icon-reorder" | |
target:self action:@selector(showMenu:) | |
withTitleTextAttributes:faTextAttributes | |
andBackgroundImage:blankImage]; | |
UIBarButtonItem *aTextButton = [UIBarButtonItem barButtonItemWithTitle:@"M" | |
target:self action:@selector(doSomething:) | |
withTitleTextAttributes:largeTextAttributes | |
andBackgroundImage:blankImage]; | |
You must have iOS FontAwesome from https://github.com/alexdrone/ios-fontawesome and the Font Awesome font itself added to your project. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment