How to develop or migrate apps for iPhone 5 screen resolution?

后端 未结 30 3752
醉话见心
醉话见心 2020-11-21 05:48

The new iPhone 5 display has a new aspect ratio and a new resolution (640 x 1136 pixels).

What is required to develop new or transition already existing applications

30条回答
  •  半阙折子戏
    2020-11-21 06:04

    Here you can find a nice tutorial (for MonoTouch, but you can use the information for Non-MonoTouch-projects, too):
    http://redth.info/get-your-monotouch-apps-ready-for-iphone-5-ios-6-today/

    1. Create a new image for your splash/default screen (640 x 1136 pixel) with the name "Default-568h@2x.png"

    2. In the iOS Simulator, go to the Hardware -> Device menu, and select "iPhone (Retina 4-inch)"

    3. Create other images, e.g. background images

    4. Detect iPhone 5 to load your new images:

    public static bool IsTall
    {
        get {
            return UIDevice.currentDevice.userInterfaceIdiom
                        == UIUserInterfaceIdiomPhone
                    && UIScreen.mainScreen.bounds.size.height
                        * UIScreen.mainScreen.scale >= 1136;
        }
    }
    

    private static string tallMagic = "-568h@2x";
    public static UIImage FromBundle16x9(string path)
    {
        //adopt the -568h@2x naming convention
        if(IsTall())
        {
            var imagePath = Path.GetDirectoryName(path.ToString());
            var imageFile = Path.GetFileNameWithoutExtension(path.ToString());
            var imageExt = Path.GetExtension(path.ToString());
            imageFile = imageFile + tallMagic + imageExt;
            return UIImage.FromFile(Path.Combine(imagePath,imageFile));
        }
        else
        {
            return UIImage.FromBundle(path.ToString());
        }
    }
    

提交回复
热议问题