我正在尝试在appcelerator中设置我的应用程序的样式。在tss文件中,我可以根据手机的型号来设置样式吗?".clsview"platform = iphone model=6s有没有提供这样的样式?
发布于 2018-02-13 01:12:19
是的,你可以用很多可能的方式来设计样式。
但首先,您应该看一下这个链接,以熟悉合金样式的工作原理:
合金允许基于true/false值定义特定的样式,如下所示:
// alloy.js
Alloy.Globals.iPhone6s = (OS_IOS && Ti.Platform.osname == "iphone" && Ti.Platform.displayCaps.platformHeight == 667);
// Since iPhone5s screen size is 640x1136, you can check for platformHeight == 568 as its DP is 2
Alloy.Globals.iPhone5s = (OS_IOS && Ti.Platform.osname == "iphone" && Ti.Platform.displayCaps.platformHeight == 568);
// in tss
".clsview"[if=Alloy.Globals.iPhone6s]
".iphone5s"[if=Alloy.Globals.iPhone5s] : {
backgroundColor : 'cyan'
}
// to apply class only on tablets, use 'formFactor = handheld/tablet'
'.tablet'[formFactor=tablet]:{color:'blue'}
'.phones'[formFactor=handheld]:{color:'red'}
// to use multiple 'if' statements inside tss, you can combine them inside alloy.jshttps://stackoverflow.com/questions/48751384
复制相似问题