第十六篇、OC_按比例适配

// 屏幕高度
#define XMGHeight [UIScreen mainScreen].bounds.size.height
// 屏幕宽度
#define XMGWidth [UIScreen mainScreen].bounds.size.width
// 以iPhone5为基准(UI妹纸给你的设计图是iPhone5的),当然你也可以改,但是出图是按照7P(6P)的图片出的,因为大图压缩还是清晰的,小图拉伸就不清晰了,所以只出一套最大的图片即可
#define XMGiPhone5W 320.0
#define XMGiPhone5H 568.0
// 计算比例
// x比例 1.293750 在iPhone7的屏幕上
#define XMGScaleX XMGWidth / XMGiPhone5W
// y比例 1.295775
#define XMGScaleY XMGHeight / XMGiPhone5H
// X坐标
#define LineX(l) l*XMGScaleX
// Y坐标
#define LineY(l) l*XMGScaleY
// 字体
#define Font(x) [UIFont systemFontOfSize:x*XMGScaleX]
原文地址:https://www.cnblogs.com/HJQ2016/p/6116305.html