【问题标题】:Platform specific with model styling appcelerator特定于平台的模型样式应用程序加速器
【发布时间】:2018-02-12 16:42:55
【问题描述】:

我正在尝试在 appcelerator 中设置我的应用程序的样式。在 tss 文件中,我可以根据手机的型号设置样式吗? ".clsview"[平台=iphone型号=6s] 有没有这种样式的规定?

【问题讨论】:

    标签: iphone appcelerator appcelerator-titanium appcelerator-mobile


    【解决方案1】:

    是的,您可以通过多种可能的方式进行样式设置。

    但首先,您应该查看此链接以熟悉 Alloy Styling 的工作原理:Alloy MVC Theme & Styling

    Alloy 允许根据 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.js
    

    【讨论】:

    • 我想创建 Alloy.Globals.iPhone5s 。我应该提出什么条件?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-26
    • 1970-01-01
    • 1970-01-01
    • 2011-09-10
    • 2016-05-22
    相关资源
    最近更新 更多