//設(shè)置星星的寬度
-(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) {//已寬度為準(zhǔn)
if (way) {
heigth = realwidth;
}else{
heigth = (width*imageHeight)/imageWidth;
}
}else{
if (way) {
width = realwidth;
}else{
width = (heigth*imageWidth)/imageHeight;
}
}
return CGSizeMake(width, heigth);
}