星星,停靠模式

来源:互联网 发布:贵州发展大数据带动 编辑:程序博客网 时间:2024/05/24 04:51
 - (id)initWithFrame:(CGRect)frame{    self = [super initWithFrame:frame];    if (self) {        _backImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 23)];        _backImgView.image = [UIImage imageNamed:@"StarsBackground.png"];        [self addSubview:_backImgView];        _frontImgView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 65, 23)];        _frontImgView.image = [UIImage imageNamed:@"StarsForeground.png"];        [self addSubview:_frontImgView];        // 图片居左停靠        _backImgView.contentMode = UIViewContentModeLeft;        _frontImgView.contentMode = UIViewContentModeLeft;        // 切除超出部分(是切图片)        _frontImgView.clipsToBounds = YES;    }    return self;} - // 根据评分 切除多余的星星--------------- - (void)setRating:(CGFloat)rating{    _rating = rating;    _frontImgView.frame = CGRectMake(0, 0, _rating/5.0*65, 23);}
0 0
原创粉丝点击