Added updateItemIconPosition function to center the TabViewItem icon when the title is not present.

This commit is contained in:
Henry Chavez
2017-05-10 17:21:44 -05:00
committed by SvetoslavTsenov
parent 1d6a47bee0
commit eb7094caaf

View File

@ -119,6 +119,10 @@ function updateItemTitlePosition(tabBarItem: UITabBarItem): void {
}
}
function updateItemIconPosition(tabBarItem: UITabBarItem): void {
tabBarItem.imageInsets = new UIEdgeInsets({top: 6, left: 0, bottom: -6, right: 0});
}
export class TabViewItem extends TabViewItemBase {
private _iosViewController: UIViewController;
@ -145,6 +149,9 @@ export class TabViewItem extends TabViewItemBase {
if (!icon) {
updateItemTitlePosition(tabBarItem);
}
else if (!title) {
updateItemIconPosition(tabBarItem);
}
// TODO: Repeating code. Make TabViewItemBase - ViewBase and move the colorProperty on tabViewItem.
// Delete the repeating code.
@ -272,6 +279,10 @@ export class TabView extends TabViewBase {
if (!icon) {
updateItemTitlePosition(tabBarItem);
}
else if (!item.title) {
updateItemIconPosition(tabBarItem);
}
applyStatesToItem(tabBarItem, states);
newController.tabBarItem = tabBarItem;