根据展示图片尺寸随屏幕尺寸变化改变

//设置星星的宽度

-(CGSize )StarWidthFunction:(NSString *)imageStr{

UIImage *DefaultImage = [UIImage imageNamed:imageStr];

CGFloat imageWidth = DefaultImage.size.width;

CGFloat imageHeight = DefaultImage.size.height;

NSInteger way = 0;// 图片的长宽相等为1 其他为0

GRLog(@"****%f,%f",imageWidth,imageHeight);

if (imageWidth==imageHeight) {

way = 1;

}

CGFloat width = (self.width-(_starTotalCount+1)*_starSpace)/(CGFloat)_starTotalCount;

CGFloat heigth = self.height-2*DQUpSpace;

CGFloat realwidth = MIN(width, heigth);

if (width<=heigth) {//已宽度为准

if (way) {

heigth = realwidth;

}else{

heigth = (width*imageHeight)/imageWidth;

}

}else{

if (way) {

width = realwidth;

}else{

width = (heigth*imageWidth)/imageHeight;

}

}

return CGSizeMake(width, heigth);

}

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容