first of all, let your own program support IPhone6 and 6+, the first use of the official provided launch Screen.xib, this directly look at official documents can, here no longer described, the second method is similar to the previous iPhone5, relatively simple, add two special PNG for IPhone6 and 6+
IPhone6: Name: [email protected] Resolution: 750*1334
6+ name: [email protected] Resolution: 1242*2208
Attention:
If you want to have the word "iphone6,6 plus optimized" in the app's introductory page, you must use the first method, or "Optimize for iPhone5" If you use the second method
Here's a look at the pure code adaptation.
First of all, the IPhone5 interface must be fully adapted to fit perfectly with 6 and 6Plus.
First of all, I'm going to look at the size-proportional relationship between 5,6 and 6Plus.
It is obvious that the size aspect ratio of the three screens is similar, so you can scale up to 6 and 6Plus on a 5 basis.
In the AppDelegate.h
1 2 |
@property float autosizescalex; @property float Autosizescaley; |
In the APPDELEGATE.M
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#define ScreenHeight [[UIScreen Mainscreen] Bounds].size.height #define SCREENWIDTH [[UIScreen Mainscreen] Bounds].size.width -(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: ( Nsdictionary *) launchoptions { appdelegate *mydelegate = [[UIApplication sharedapplication] delegate]; if(ScreenHeight > 480) { mydelegate.autosizescalex = screenwidth/320; Mydelegate.autosizescaley = screenheight/568; }else{ Mydelegate.autosizescalex = 1.0; Mydelegate.autosizescaley = 1.0; } } |
Because the height of the iphone4s screen is 480, when the screen size is greater than iPhone4, Autosizescalex and Autosizescaley are the aspect ratios of the current screen and iPhone5 dimensions. Like what
If it is 5,autosizescalex=1,autosizescaley=1;
If it is 6,autosizescalex=1.171875,autosizescaley=1.17429577;
If it is 6plus,autosizescalex=1.29375,autosizescaley=1.2957;
Now that we have a proportional relationship, let's take a look at how to fit the Code Setup interface.
CGRectMake (CGFloat x, cgfloat y, cgfloat width, cgfloat height) This method makes it common for us to set the size of the method, and now I set up a method similar to this one.
In the. m file
1 2 3 4 5 6 7 8 9 10 11 |
Uiimageview *imageview = [[Uiimageview alloc] initWithFrame:CGRectMake1(100, 100, 50, 50)]; Cg_inline CGRect CGRectMake1 (CGFloat x, cgfloat y, cgfloat width, cgfloat height) { appdelegate *mydelegate = [[UIApplication sharedapplication] delegate]; cgrect rect; rect.origin.x = x * Mydelegate.autosizescalex; rect.origin.y = y * Mydelegate.autosizescaley; rect.size.width = width * Mydelegate.autosizescalex; rect.size.height = height * Mydelegate.autosizescale Y; return rect; } |
In this way, the BTN button is in the same position and size ratio as the 5,6 and 6Plus.
If the whole project is done before you start to adapt the advantages of this method is reflected in the face of dozens of project files, just customize and replace your CGRectMake method, plus Storyboradautolay This method to complete the most even all of the full adaptation, If you encounter TableView or other manual adjustments can be.
iOS Pure Code manual adaptation