This is a fork from jasarien/JSFavStarControl.
AMRatingControl is a UI control that resembles the 'star rating' control seen in the iPod app.
AMRatingControl allows you to select a rating starting from 0 to any number of stars you want.
You can use default star symbols and customize colors or specify custom images.
- Using CocoaPods
pod 'AMRatingControl'
- Without CocoaPods
Add AMRatingControl.h
and AMRatingControl.m
to your project.
#include "AMRatingControl.h"
// Create a simple instance, initing with :
// - a CGPoint (the position in your view from which it will be drawn)
// - and max rating
AMRatingControl *simpleRatingControl = [[AMRatingControl alloc] initWithLocation:(CGPoint)location
andMaxRating:(NSInteger)maxRating];
// Customize the current rating if needed
[ratingControl setRating:(NSInteger)rating];
// Define block to handle events
simpleRatingControl.editingChangedBlock = ^(NSUInteger rating)
{
[label setText:[NSString stringWithFormat:@"%d", rating]];
};
simpleRatingControl.editingDidEndBlock = ^(NSUInteger rating)
{
[endLabel setText:[NSString stringWithFormat:@"%d", rating]];
};
// Create an instance with images, initing with :
// - a CGPoint (the position in your view from which it will be drawn)
// - a custom empty image and solid image if you wish (pass nil if you want to use the default).
// - and max rating
AMRatingControl *imagesRatingControl = [[AMRatingControl alloc] initWithLocation:(CGPoint)location
emptyImage:(UIImage *)emptyImageOrNil
solidImage:(UIImage *)solidImageOrNil
andMaxRating:(NSInteger)maxRating];
// Create an instance with custom colors, initing with :
// - a CGPoint (the position in your view from which it will be drawn)
// - a custom empty image and solid image if you wish (pass nil if you want to use the default).
// - and max rating
AMRatingControl *coloredRatingControl = [[AMRatingControl alloc] initWithLocation:(CGPoint)location
emptyColor:(UIColor *)emptyColorOrNi
solidColor:(UIColor *)solidColorOrNi
andMaxRating:(NSInteger)maxRating];
// Add the control(s) as subview of your view
[view addSubview:simpleRatingControl];
[view addSubview:imagesRatingControl];
[view addSubview:coloredRatingControl];
AMRatingControl uses ARC.
AMRatingControl is available under the MIT license. See the LICENSE file for more info.