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

//设置星星的宽度

-(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);

}

你可能感兴趣的:(根据展示图片尺寸随屏幕尺寸变化改变)