.config(function($stateProvider, $urlRouterProvider,$ionicConfigProvider) {
$ionicConfigProvider.tabs.position('bottom'); //top
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html'
})
.
.
.
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/dash');
});
8 回答
自Ionic(http://blog.ionic.io/the-final-beta/)的 beta 14 以来,有一些配置变量现在默认为它们的平台值,这意味着它们将尝试根据它们构建的平台来运行 . 对于标签,对于iOS,默认显示在底部,Android显示在顶部 .
您可以通过在配置函数中的
$ionicConfigProvider
中设置tabs.position
函数轻松地"hard set"所有平台的位置,如下所示:你可以查看文档here
要将ionicFramework选项卡放置在Android设备的屏幕底部,只需打开 app.js 文件,然后在 angular.module 下添加以下代码行:
希望这会有所帮助 .
Ionic 2的更新(更清晰/改进的语法):
在app.js中:
See Configs
将它放在app.js中可以完成工作 .
Ionic自动将平台配置考虑在内,以调整使用的过渡样式以及标签图标是否应显示在顶部或底部 .
例如,对于标签,对于iOS,默认显示在底部,Android显示在顶部 .
Note1 : It should be noted that when a platform is not iOS or Android, then it’ll default to iOS
Note2 : if you are developing on a desktop browser, it’s going to take on iOS default configs
在app.js文件的旁边,您需要将$ ionicConfigProvider注入.config模块并添加 $ionicConfigProvider.tabs.position(‘bottom’)
如何在Ionic 2中将离子标签置于屏幕底部
对于当前版本的离子2.0.0-beta.10 .
在app.ts:
见Config
对于即将发布的离子2.0.0-beta.11
在app.ts:
Config
Ionic 2和Ionic 3的更新:
您有2种方法可以更改标签栏位置:
Method 1: Use tabsPlacement propertive of <ion-tabs>
Method 2: Change config in app.module.ts
见docs