mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
@@ -237,6 +237,13 @@ export class TabView extends View implements definition.TabView, AddArrayFromBui
|
||||
this.style.textTransform = value;
|
||||
}
|
||||
|
||||
get iosIconRenderingMode(): string {
|
||||
return undefined;
|
||||
}
|
||||
set iosIconRenderingMode(value: string) {
|
||||
//
|
||||
}
|
||||
|
||||
public _onSelectedIndexPropertyChangedSetNativeValue(data: PropertyChangeData) {
|
||||
var index = this.selectedIndex;
|
||||
if (types.isUndefined(index)) {
|
||||
|
||||
9
tns-core-modules/ui/tab-view/tab-view.d.ts
vendored
9
tns-core-modules/ui/tab-view/tab-view.d.ts
vendored
@@ -105,6 +105,15 @@ declare module "ui/tab-view" {
|
||||
*/
|
||||
ios: any /* UITabBarController */;
|
||||
|
||||
/**
|
||||
* Gets or set the UIImageRenderingMode of the tab icons in iOS.
|
||||
* Valid values are:
|
||||
* - automatic
|
||||
* - alwaysOriginal
|
||||
* - alwaysTemplate
|
||||
*/
|
||||
iosIconRenderingMode: string;
|
||||
|
||||
/**
|
||||
* String value used when hooking to the selectedIndexChanged event.
|
||||
*/
|
||||
|
||||
@@ -125,6 +125,7 @@ export class TabViewItem extends common.TabViewItem {
|
||||
public _update() {
|
||||
if (this._parent && this._controller) {
|
||||
var icon = this._parent._getIcon(this.iconSource);
|
||||
//TODO: Implement initWithSystemItem to support standard system icons
|
||||
var tabBarItem = UITabBarItem.alloc().initWithTitleImageTag((this.title || ""), icon, this._parent.items.indexOf(this));
|
||||
if (!icon) {
|
||||
if (types.isFunction((<any>tabBarItem).setTitlePositionAdjustment)) {
|
||||
@@ -301,6 +302,36 @@ export class TabView extends common.TabView {
|
||||
}
|
||||
}
|
||||
|
||||
private _iconRenderingMode: string;
|
||||
get iosIconRenderingMode(): string {
|
||||
return this._iconRenderingMode;
|
||||
}
|
||||
set iosIconRenderingMode(value: string) {
|
||||
if (this._iconRenderingMode !== value){
|
||||
this._iconRenderingMode = value;
|
||||
this._iconsCache = {};
|
||||
if (this.items && this.items.length){
|
||||
for (let i = 0, length = this.items.length; i < length; i++) {
|
||||
if (this.items[i].iconSource) {
|
||||
(<any>this.items[i])._update();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private _getIconRenderingMode(): UIImageRenderingMode {
|
||||
switch(this._iconRenderingMode) {
|
||||
case "alwaysOriginal":
|
||||
return UIImageRenderingMode.AlwaysOriginal;
|
||||
case "alwaysTemplate":
|
||||
return UIImageRenderingMode.AlwaysTemplate;
|
||||
case "automatic":
|
||||
default:
|
||||
return UIImageRenderingMode.Automatic;
|
||||
}
|
||||
}
|
||||
|
||||
public _getIcon(iconSource: string): UIImage {
|
||||
if (!iconSource) {
|
||||
return null;
|
||||
@@ -313,7 +344,7 @@ export class TabView extends common.TabView {
|
||||
|
||||
var is = imageSource.fromFileOrResource(iconSource);
|
||||
if (is && is.ios) {
|
||||
var originalRenderedImage = is.ios.imageWithRenderingMode(UIImageRenderingMode.Automatic);
|
||||
var originalRenderedImage = is.ios.imageWithRenderingMode(this._getIconRenderingMode());
|
||||
this._iconsCache[iconSource] = originalRenderedImage;
|
||||
image = originalRenderedImage;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user