Add support for tab bar tint (only on iOS 5 or newer)

This commit is contained in:
Andreas Sommer
2012-08-17 15:16:15 +01:00
parent 2749a2a8c5
commit 0621d259ad
3 changed files with 23 additions and 5 deletions

View File

@@ -58,6 +58,9 @@ This example shows how to use the tab bar:
plugins.tabBar.init()
plugins.tabBar.create()
// or with an orange tint:
plugins.tabBar.create({selectedImageTintColorRgba: '255,40,0,255'})
plugins.tabBar.createItem("contacts", "Unused, iOS replaces this text by Contacts", "tabButton:Contacts")
plugins.tabBar.createItem("recents", "Unused, iOS replaces this text by Recents", "tabButton:Recents")

View File

@@ -15,9 +15,13 @@ function TabBar() {
/**
* Create a native tab bar that can have tab buttons added to it which can respond to events.
*
* @param options Additional options:
* - selectedImageTintColorRgba: Tint color for selected items (defaults to standard light blue), must define the
* color as string e.g. '255,0,0,128' for 50% transparent red. This is only supported on iOS 5 or newer.
*/
TabBar.prototype.create = function() {
cordova.exec("TabBar.create");
TabBar.prototype.create = function(options) {
cordova.exec("TabBar.create", options);
};
/**

View File

@@ -132,11 +132,22 @@
tabBar.autoresizesSubviews = YES;
tabBar.hidden = YES;
tabBar.userInteractionEnabled = YES;
tabBar.opaque = YES;
tabBar.opaque = YES;
self.webView.superview.autoresizesSubviews = YES;
NSString *iconTint = [options valueForKey:@"selectedImageTintColorRgba"];
[ self.webView.superview addSubview:tabBar];
if(iconTint && [tabBar respondsToSelector:@selector(setSelectedImageTintColor:)])
{
NSArray *rgba = [iconTint componentsSeparatedByString:@","];
tabBar.selectedImageTintColor = [UIColor colorWithRed:[[rgba objectAtIndex:0] intValue]/255.0f
green:[[rgba objectAtIndex:1] intValue]/255.0f
blue:[[rgba objectAtIndex:2] intValue]/255.0f
alpha:[[rgba objectAtIndex:3] intValue]/255.0f];
}
self.webView.superview.autoresizesSubviews = YES;
[self.webView.superview addSubview:tabBar];
}
-(void) init:(NSMutableArray *)arguments withDict:(NSMutableDictionary *)options