纯代码开发屏幕适配处理方法:
为适配iphone各个版本的机型,对ui布局中的坐标采用比例的方式进行初始化,在这里选定iphone6作为ui布局
1.首先在AppDelegate.h中定义两个属性:
1 #import
2
3 @interface AppDelegate : UIResponder
4
5 @property (strong, nonatomic) UIWindow *window;6
7
8 @property(nonatomic,assign)CGFloat autoSizeScaleX;9 @property(nonatomic,assign)CGFloat autoSizeScaleY;10
11 @end
2.在AppDelegate.m中对属性进行初始化(计算出当前运行的iphone版本的屏幕尺寸跟设计ui时选定的iphone6的比例):
#import "AppDelegate.h"
@interfaceAppDelegate ()@end
@implementationAppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {//Override point for customization after application launch.
self.autoSizeScaleX= [UIScreen mainScreen].bounds.size.width/375;
self.autoSizeScaleY= [UIScreen