一:
#define kScreenHeight [UIScreen mainScreen].bounds.size.height
#define kScreenWith [UIScreen mainScreen].bounds.size.width
//当前屏幕与设计尺寸(iPhone6)宽度比例
@property(nonatomic,assign)CGFloat autoSizeScaleW;
//当前屏幕与设计尺寸(iPhone6)高度比例
@property(nonatomic,assign)CGFloat autoSizeScaleH;
二:
实现自定义方法- (void)initAutoScaleSize;
- (CGFloat)initAutoScaleSize{
//[UIScreen mainScreen].bounds.size.width
if (kScreenHeight==480) {
//4s
self.autoSizeScaleW = kScreenWith/736;
//_autoSizeScaleH = kScreenHeight/414;
}else if(kScreenHeight==568) {
//5
self.autoSizeScaleW =kScreenWith/736;
//_autoSizeScaleH =kScreenHeight/414;
}else if(kScreenHeight==667){
//6
self.autoSizeScaleW =kScreenWith/736;
//_autoSizeScaleH =kScreenHeight/414;
}else if(kScreenHeight==736){
//6p
self.autoSizeScaleW =kScreenWith/736;
//_autoSizeScaleH =kScreenHeight/414;
}else if (kScreenHeight==1024){
self.autoSizeScaleW =kScreenWith/736;
}else{
self.autoSizeScaleW=kScreenWith/736;
}
return self.autoSizeScaleW;
}
4.写控件时设置字体大小:
[UIFontsystemFontOfSize:autoScaleW(14)]
设置frame:
CGRectMake(CGRectGetMaxX(self.productNameLabel.frame) + 10 , self.productNameLabel.top+3,autoScaleW(32),autoScaleW(17));
顶
1