首页 > 随笔档案 > iOS 屏幕适配

iOS 屏幕适配

Publish:

#define WIDTH CGRectGetWidth([UIScreen mainScreen].bounds)
#define HEIGHT CGRectGetHeight([UIScreen mainScreen].bounds)
#define Screen [UIScreen mainScreen].bounds
 
#define autoSizeScaleX (WIDTH>480?WIDTH/320.0:1.0)
#define autoSizeScaleY (WIDTH>480?HEIGHT/568.0:1.0)
#define WidthScale (autoSizeScaleX*WIDTH/750.0)
#define HeightScale (autoSizeScaleY*HEIGHT/1334.0)
 
CG_INLINE CGRect
CGLFLMake(CGFloat x, CGFloat y, CGFloat width, CGFloat height)
{
     
    CGRect rect;
    rect.origin.x = x *autoSizeScaleX;
    rect.origin.y = y *autoSizeScaleY;
    rect.size.width = width *autoSizeScaleX;
    rect.size.height = height *autoSizeScaleY;
    return rect;
}
 
CG_INLINE CGPoint
CGPointLFLMake(CGFloat x, CGFloat y)
{
    CGPoint pointLFL;
    pointLFL.x = x * autoSizeScaleX;
    pointLFL.y = y * autoSizeScaleY;
    return pointLFL;
}
 
CG_INLINE CGSize
CGSizeLFLMake(CGFloat width, CGFloat height)
{
    CGSize sizeLFL;
    sizeLFL.width = width* autoSizeScaleX;
    sizeLFL.height = height* autoSizeScaleY;
    return sizeLFL;
}
 
#define FontScale 72.0/96.0

声明: 本文采用 BY-NC-SA 授权。转载请注明转自: levy