//星级
[self.startView setStarLevelFormStr:model.starCurrent];
- (void)createUI{
//在当前图片上放置五星级图片
UIImageView * upImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 23)];
upImageView.tag = 2000;
upImageView.image = [UIImage imageNamed:@"StarsForeground"];
[self addSubview:upImageView];
//执行切割多余部分的操作
upImageView.clipsToBounds = YES;
//停靠模式 使五星级图片停靠在父视图的左侧 不设置会自动拉伸
upImageView.contentMode = UIViewContentModeLeft;
}
- (void)setStarLevelFormStr:(NSString *)level{
//更改五星级图片
UIImageView * imageView = (UIImageView *)[self viewWithTag:2000];
//@"4.5"->float4.5
imageView.frame = CGRectMake(0, 0, (level.doubleValue/5.0)*65, 23);