mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-04-24 03:00:11 -04:00
Add support for tab bar tint (only on iOS 5 or newer)
This commit is contained in:
@@ -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")
|
||||
|
||||
|
||||
@@ -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);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user