HCSStarRatingView
is a UIControl
subclass to easily provide users with a basic star-rating interface.
It supports all device resolutions and requires no images do render the stars, thanks to PaintCode.
Via CocoaPods, add this line to your Podfile
pod 'HCSStarRatingView', :git => 'https://github.com/hugocampossousa/HCSStarRatingView.git'
and run pod install
You can also install it manually by copying HCSStarRatingView.h and HCSStarRatingView.m into your project.
You can create a new rating view programatically by importing HCSStarRatingView.h and HCSStarRatingView.m into your project and:
#import "HCSStarRatingView.h"
HCSStarRatingView *starRatingView = [[HCSStarRatingView alloc] initWithFrame:CGRectMake(50, 200, 200, 50)];
starRatingView.maximumValue = 10;
starRatingView.minimumValue = 0;
starRatingView.value = 0;
starRatingView.tintColor = [UIColor redColor];
[starRatingView addTarget:self action:@selector(didChangeValue:) forControlEvents:UIControlEventValueChanged];
[self.view addSubview:starRatingView];
It also supports half-star ratings:
starRatingView.allowsHalfStars = YES;
starRatingView.value = 2.5f;
HCSStarRatingView
also implements IB_DESIGNABLE and IBInspectable so you can fully customize it in Interface Builder.
Hugo Sousa
HCSStarRatingView is available under the MIT license. See the LICENSE file for more info.