Aravindh Aravindh - 5 months ago 79
Swift Question

How to detect iPhone 6 or iPhone 6 Plus view size mode programmatically

I want to detect iOS device screen size and load different storyboards based on that.Any idea how to achieve this in Swift.

is there any default properties like

if #available(iOS 9.0, *) {
// load zoomed storyboard
}else{
// load standard storyboard
}

Answer

This works for me tested in iphone 6+ and 6s+

if #available(iOS 8.0, *) {
                print("ios greater than 8")
                if(UIScreen.mainScreen().bounds.size.height == 667.0 && UIScreen.mainScreen().nativeScale < UIScreen.mainScreen().scale){
//                    iphone 6+ and 6s+ are in zoomed
                    print("iphone 6+ and 6s+ zoomed ")
                }else{
                    //                    iphone 6+ and 6s+ are in standard 
                    print("iphone 6+ and 6s+ standard ")
                }
            }else{
                print("ios less than 8")
            }

thanks @k8mil

Comments