标签:tps base code nslog 图片 ali 屏幕高度 手机 fine
#ifndef ScreenAdaptation_pch
#define ScreenAdaptation_pch
/************ 机子屏幕高度与宽度 *****************************/
#define CHScreenH [UIScreen mainScreen].bounds.size.height
#define CHScreenW [UIScreen mainScreen].bounds.size.width
/****** 屏幕适配,以iphone 6 Plus 为基准 **************/
#define HEIGHT_BASE 736
#define WIDTH_BASE 414
/******** 点适配 ********/
#define ScaleH(HEIGHT) CHScreenH / HEIGHT_BASE * HEIGHT
#define ScaleW(WIDTH) CHScreenW / WIDTH_BASE * WIDTH
/******** 字体适配 ********/
#define ScaleFront(front) CHScreenH / HEIGHT_BASE * front
#endif /* ScreenAdaptation_pch */
UIView *view = [[UIView alloc] init];
view.frame = CGRectMake(ScaleW(10), ScaleH(10), CHScreenW - ScaleW(20), 0.5 * CHScreenH - ScaleH(20));
view.backgroundColor = [UIColor redColor];
NSLog(@"%f-----%f", ScaleW(10), ScaleH(10));
[self.view addSubview:view];
UILabel *label = [[UILabel alloc] init];
label.frame = CGRectMake(ScaleW(10), 0.5 * CHScreenH + ScaleH(10), CHScreenW - ScaleW(20), 0.5 * CHScreenH - ScaleH(20));
label.text = @"屏幕字体适配呵呵呵";
label.textAlignment = NSTextAlignmentCenter;
[label setFont:[UIFont systemFontOfSize:ScaleFront(40)]];
[self.view addSubview:label];
大屏幕iphone 6 Plus
小屏幕iphone 5s
标签:tps base code nslog 图片 ali 屏幕高度 手机 fine
原文地址:https://www.cnblogs.com/CH520/p/9260053.html