如何支持钛合金XML中的不同分辨率

时间:2013-11-28 12:58:28

标签: ios iphone titanium titanium-alloy

我正在使用Titanium Alloy框架,问题是我已根据iphone 5设置了尺寸参数。当我为iphone 4编译时,在UI中出现了某种干扰。

简而言之,我希望能够在钛合金的.tss.xml文件中处理iphone 4和5中的不同屏幕分辨率。

2 个答案:

答案 0 :(得分:1)

您可以尝试根据以下链接设置条件。

http://developer.appcelerator.com/question/159770/do-we-have-any-conditions-to-handle-in-xml-file#comment-195451

代替Alloy.Globals.isIOS7,您可以使用自己的boollean全局变量来检查其iphone 4或5。

答案 1 :(得分:0)

@Mitul Bhalia是对的。

1.检测特定的屏幕分辨率:

// app/alloy.js
Alloy.Globals.isIos7Plus = (OS_IOS && parseInt(Ti.Platform.version.split(".")[0]) >= 7);
Alloy.Globals.iPhoneTall = (OS_IOS && Ti.Platform.osname == "iphone" && Ti.Platform.displayCaps.platformHeight == 568); 

2.write查询样式tss:

// Query styles
"#info[if=Alloy.Globals.isIos7Plus]" : {
    font : { textStyle : Ti.UI.TEXT_STYLE_FOOTNOTE }
},
"#title[if=Alloy.Globals.isIos7Plus]" : {
    top: '25dp', // compensate for the status bar on iOS 7
    font : { textStyle : Ti.UI.TEXT_STYLE_HEADLINE }
},
"#content[if=Alloy.Globals.isIos7Plus]" : {
    font : { textStyle : Ti.UI.TEXT_STYLE_CAPTION1 }
},
"ScrollView[if=Alloy.Globals.iPhoneTall]" : {
    height : '500dp'
}

请参阅:http://docs.appcelerator.com/titanium/3.0/#!/guide/Alloy_Styles_and_Themes-section-35621526_AlloyStylesandThemes-Platform-SpecificStyles

请参阅:https://stackoverflow.com/a/28298508/445908

相关问题