Created
December 2, 2012 09:23
-
-
Save devgeeks/4187933 to your computer and use it in GitHub Desktop.
Snippet needed to add a raised TabBar button in PhoneGap to the TabBar or NativeControls plugin on iOS
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
UIImage* buttonImage = [UIImage imageNamed:@"aperture-tab.png"]; | |
UIButton* button = [UIButton buttonWithType:UIButtonTypeCustom]; | |
button.frame = CGRectMake(0.0, 0.0, buttonImage.size.width, buttonImage.size.height); | |
[button setBackgroundImage:buttonImage forState:UIControlStateNormal]; | |
[button setBackgroundImage:buttonImage forState:UIControlStateHighlighted]; | |
CGFloat heightDifference = buttonImage.size.height - tabBar.frame.size.height; | |
CGPoint center = tabBar.center; | |
center.y = center.y - heightDifference/2.0; | |
button.center = center; | |
[ tabBar addSubview:button]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment