mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 19:26:42 +08:00
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import tabViewModule = require("tns-core-modules/ui/tab-view");
|
|
|
|
export function getNativeTabCount(tabView: tabViewModule.TabView): number {
|
|
if (!tabView.ios.viewControllers) {
|
|
return 0;
|
|
}
|
|
|
|
return tabView.ios.viewControllers.count;
|
|
}
|
|
|
|
export function selectNativeTab(tabView: tabViewModule.TabView, index: number): void {
|
|
tabView.ios.selectedIndex = index;
|
|
tabView.ios.delegate.tabBarControllerDidSelectViewController(tabView.ios, tabView.ios.selectedViewController);
|
|
}
|
|
|
|
export function getNativeSelectedIndex(tabView: tabViewModule.TabView): number {
|
|
return tabView.ios.selectedIndex;
|
|
}
|
|
|
|
export function getNativeFont(tabView: tabViewModule.TabView): UIFont {
|
|
const tabBar = <UITabBar>tabView.ios.tabBar;
|
|
if (tabBar.items.count > 0) {
|
|
const currentAttrs = tabBar.items[0].titleTextAttributesForState(UIControlState.Normal);
|
|
if (currentAttrs) {
|
|
return currentAttrs.objectForKey(NSFontAttributeName);
|
|
}
|
|
}
|
|
|
|
return null;
|
|
}
|
|
|
|
export function getOriginalFont(tabView: tabViewModule.TabView): UIFont {
|
|
return tabView.style.fontInternal.getUIFont(UIFont.systemFontOfSize(10));
|
|
}
|