Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect iPhone X with Appcelerator

I am using custom navbar for my project and I am using codes for ios 7 top margin as below;

var _IsIos7Plus = false;

if (Titanium.Platform.name == 'iPhone OS') {
    var _Version = Titanium.Platform.version.split(".");
    var _Major = parseInt(_Version[0], 10);

    if (_Major >= 7) {
        _IsIos7Plus = true;
    }
}

Alloy.Globals.Ios7TopMargin = _IsIos7Plus  == true ? 20 : 0;

But iPhone X simulator shows 20 blank. Is there any way to detect iPhone X?

iPhone X iOS 11.2 Screenshot

iPhone 8 iOS 11.2 Screenshot

like image 579
Kerberos Avatar asked Apr 28 '26 06:04

Kerberos


1 Answers

If you upgrade your project firstly you should check

[email protected]

[email protected]

splash screens are exists

Than you can detect iPhoneX code as below;

var IsIphoneX = (Ti.Platform.displayCaps.platformWidth === 375 && Ti.Platform.displayCaps.platformHeight === 812 && Ti.Platform.displayCaps.logicalDensityFactor === 3);
like image 193
Kerberos Avatar answered Apr 29 '26 23:04

Kerberos



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!