Skip to content

Commit eb7094c

Browse files
henrychavezSvetoslavTsenov
authored andcommitted
Added updateItemIconPosition function to center the TabViewItem icon when the title is not present.
1 parent 1d6a47b commit eb7094c

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tns-core-modules/ui/tab-view/tab-view.ios.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ function updateItemTitlePosition(tabBarItem: UITabBarItem): void {
119119
}
120120
}
121121

122+
function updateItemIconPosition(tabBarItem: UITabBarItem): void {
123+
tabBarItem.imageInsets = new UIEdgeInsets({top: 6, left: 0, bottom: -6, right: 0});
124+
}
125+
122126
export class TabViewItem extends TabViewItemBase {
123127
private _iosViewController: UIViewController;
124128

@@ -145,6 +149,9 @@ export class TabViewItem extends TabViewItemBase {
145149
if (!icon) {
146150
updateItemTitlePosition(tabBarItem);
147151
}
152+
else if (!title) {
153+
updateItemIconPosition(tabBarItem);
154+
}
148155

149156
// TODO: Repeating code. Make TabViewItemBase - ViewBase and move the colorProperty on tabViewItem.
150157
// Delete the repeating code.
@@ -272,6 +279,10 @@ export class TabView extends TabViewBase {
272279
if (!icon) {
273280
updateItemTitlePosition(tabBarItem);
274281
}
282+
else if (!item.title) {
283+
updateItemIconPosition(tabBarItem);
284+
}
285+
275286
applyStatesToItem(tabBarItem, states);
276287

277288
newController.tabBarItem = tabBarItem;

0 commit comments

Comments
 (0)