2013-11-28 41 views
1

我正在使用钛合金框架,问题是我根据iphone 5设置了尺寸参数。当我为iphone 4编译时,UI中出现了一些干扰。如何在钛合金中支持不同的分辨率合金XML

总之,我想要在钛合金中的.tss.xml文件中处理iPhone 4和5中不同屏幕分辨率的方式。

回答

0

@Mitul Bhalia是否正确。

1.detect具体的屏幕分辨率:

// 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