mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 05:18:39 +08:00
Added updateItemIconPosition function to center the TabViewItem icon when the title is not present.
This commit is contained in:

committed by
SvetoslavTsenov

parent
1d6a47bee0
commit
eb7094caaf
@ -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;
|
||||
|
Reference in New Issue
Block a user