Ionic:android 和 iOS 的样式相同
Ionic: same style for android and iOS
在此视频中 (https://www.youtube.com/watch?v=ZjPRj2Vp74U) Andrew 提到 Ionic 为每个平台构建了不同的元素设计。是否可以避免这种情况,让应用在所有平台上看起来都一样?
是的,这是 100% 的可能性。
这可以通过 Ionic $ionicConfigProvider
实现。您可以在 .config()
方法中使用此提供程序,并执行诸如覆盖您想要的平台特定样式之类的操作。
这是一个非常强大的工具。查看 docs 了解完整信息。
如果您使用的是 Ionic2...
打开app/app.ts
并添加下一个配置:
ionicBootstrap(MyApp, [], {
mode: 'ios' // use 'md' for android and 'wp' for windows
})
The ionic.Platform utility can be used in your JavaScript controller
to set the platform for your app.
实际上它可以设置和获取平台,诀窍是 运行 在 运行 方法中为您的模块设置命令,然后再设置其他所有内容:
angular.module('YourAppName').run(function () {
//override platform
ionic.Platform.setPlatform("android");//all styles will be unified on both Android and iOS
});
对于 Ionic 2.0.0 您可以使用 IonicModule forRoot 方法的配置参数。
IonicModule.forRoot(MyApp, {mode: 'ios'}),
在此视频中 (https://www.youtube.com/watch?v=ZjPRj2Vp74U) Andrew 提到 Ionic 为每个平台构建了不同的元素设计。是否可以避免这种情况,让应用在所有平台上看起来都一样?
是的,这是 100% 的可能性。
这可以通过 Ionic $ionicConfigProvider
实现。您可以在 .config()
方法中使用此提供程序,并执行诸如覆盖您想要的平台特定样式之类的操作。
这是一个非常强大的工具。查看 docs 了解完整信息。
如果您使用的是 Ionic2...
打开app/app.ts
并添加下一个配置:
ionicBootstrap(MyApp, [], {
mode: 'ios' // use 'md' for android and 'wp' for windows
})
The ionic.Platform utility can be used in your JavaScript controller to set the platform for your app.
实际上它可以设置和获取平台,诀窍是 运行 在 运行 方法中为您的模块设置命令,然后再设置其他所有内容:
angular.module('YourAppName').run(function () {
//override platform
ionic.Platform.setPlatform("android");//all styles will be unified on both Android and iOS
});
对于 Ionic 2.0.0 您可以使用 IonicModule forRoot 方法的配置参数。
IonicModule.forRoot(MyApp, {mode: 'ios'}),