使 Ionic 1 拨动开关看起来像 Android 上的 iOS
Make Ionic 1 toggle switch look like the iOS one on Android
我正在开发一个带有拨动开关的 Ionic 1 项目。你知道:
<ion-toggle>hello</ion-toggle>
Android 和 iOS 看起来不一样,我更喜欢 iOS。我知道在 Ionic 2 中,我可以这样做:
<ion-toggle mode="ios">hello</ion-toggle>
但这是一个 Ionic 1 项目,我不想为此将其转换为 Ionic 2。我运气不好吗?
是的,您可以使用以下两个选项来完成:
$ionicConfigProvider
。您可以使用它配置很多东西(style/value/animation 等)。在 myApp.config()
. 中使用
用法:
var myApp = angular.module('reallyCoolApp', ['ionic']);
myApp.config(function($ionicConfigProvider) {
$ionicConfigProvider.views.maxCache(5);
// note that you can also chain configs
$ionicConfigProvider.backButton.text('Go Back').icon('ion-chevron-left');
});
您的要求:
您需要使用 ``
设置切换项的样式
form.toggle(value) Toggle item style. Android defaults to small
and
iOS defaults to large
.
如果您想为项目中的所有切换设置样式,请使用以下内容:
$ionicConfigProvider.form.toggle('large');
在 link 处检查 form.toggle
:
- 使用 CSS class:
将
class="toggle-large"
添加到 ion-toggle
如下所示以设置特定切换样式:
<ion-toggle class="toggle-large">hello</ion-toggle>
工作示例代码:
我正在开发一个带有拨动开关的 Ionic 1 项目。你知道:
<ion-toggle>hello</ion-toggle>
Android 和 iOS 看起来不一样,我更喜欢 iOS。我知道在 Ionic 2 中,我可以这样做:
<ion-toggle mode="ios">hello</ion-toggle>
但这是一个 Ionic 1 项目,我不想为此将其转换为 Ionic 2。我运气不好吗?
是的,您可以使用以下两个选项来完成:
$ionicConfigProvider
。您可以使用它配置很多东西(style/value/animation 等)。在myApp.config()
. 中使用
用法:
var myApp = angular.module('reallyCoolApp', ['ionic']);
myApp.config(function($ionicConfigProvider) {
$ionicConfigProvider.views.maxCache(5);
// note that you can also chain configs
$ionicConfigProvider.backButton.text('Go Back').icon('ion-chevron-left');
});
您的要求: 您需要使用 ``
设置切换项的样式form.toggle(value) Toggle item style. Android defaults to
small
and iOS defaults tolarge
.
如果您想为项目中的所有切换设置样式,请使用以下内容:
$ionicConfigProvider.form.toggle('large');
在 link 处检查 form.toggle
:
- 使用 CSS class:
将
class="toggle-large"
添加到ion-toggle
如下所示以设置特定切换样式:
<ion-toggle class="toggle-large">hello</ion-toggle>
工作示例代码: