3

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

Kerberos
  • 331
  • 1
  • 11

1 Answers1

5

If you upgrade your project firstly you should check

Default-Portrait-2436h@3x.png

Default-Landscape-2436h@3x.png

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);
Kerberos
  • 331
  • 1
  • 11