Skip to content

Instantly share code, notes, and snippets.

@devgeeks
Created December 2, 2012 09:23
Show Gist options
  • Save devgeeks/4187933 to your computer and use it in GitHub Desktop.
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
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