//
//  GMRateView.m
//  Gengmei
//
//  Created by Thierry on 1/22/15.
//  Copyright (c) 2015 Wanmeichuangyi. All rights reserved.
//

#import "GMRateView.h"
#import <Masonry/Masonry.h>

@implementation GMRateView


- (void)initView
{
    for (int i=0; i<5; i++) {
        UIImageView *rateImage = [[UIImageView alloc] init];
        [rateImage setImage:[UIImage imageNamed:@"star_empty"]];
        [self addSubview:rateImage];
        [rateImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.mas_left).offset(i*19);
            make.top.equalTo(self.mas_top);
            make.size.mas_equalTo(CGSizeMake(15, 15));
        }];
    }

}

- (void)layoutSubviews
{
    [super layoutSubviews];
    for (int i=0; i<(_rate > 5 ? 5 : _rate); i++) {
        UIImageView *rateImage = self.subviews[i];
        [rateImage setImage:[UIImage imageNamed:@"star_full"]];
    }
}

@end
