Giter VIP home page Giter VIP logo

starratingcontrol's Introduction

StarRatingControl

This is a fork from amseddi/AMRatingControl.

StarRatingControl is a UI control that resembles the 'star rating' control seen in the iPod app.

StarRatingControl 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.

How To Get Started

Add StarRatingControl.h and StarRatingControl.m to your project.

Example Usage

    #import "StarRatingControl.h"
    
    // Create a simple instance, initing with :
    // - a CGPoint (the position in your view from which it will be drawn)
    // - and max rating
	StarRatingControl *simpleRatingControl = [[StarRatingControl alloc] initWithLocation:CGPointMake(90, 50)
                                                                        andMaxRating:5];
    
    // Customize the current rating if needed
    [simpleRatingControl setRating:3];
    [simpleRatingControl setStarSpacing:10];
    
    // 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).
    // - initial rating (how many stars the rating will have initially when displayed)
    // - and max rating
    // This control, when initialized with (at least) the fullStar image will support partial rating stars, i.e., 3.5
	UIImage *emptyStar, *fullStar;
	emptyStar = [UIImage imageNamed:@"star_rating_empty.png"];
	fullStar = [UIImage imageNamed:@"star_rating_full.png"];
  
	StarRatingControl *imagesRatingControl = [[StarRatingControl alloc] initWithLocation:CGPointMake(110, 250)
                                                                          emptyImage:emptyStar
                                                                          solidImage:fullStar
                                                                       initialRating:3.5
                                                                        andMaxRating:5];
  
    // Create an instance with custom color, initing with :
    // - a CGPoint (the position in your view from which it will be drawn)
    // - colors for "empty" and "full" rating stars
    // - and max rating
	StarRatingControl *coloredRatingControl = [[StarRatingControl alloc] initWithLocation:CGPointMake(110, 370)
                                                                           emptyColor:[UIColor yellowColor]
                                                                           solidColor:[UIColor redColor]
                                                                         andMaxRating:5];
    

// Add the control(s) as subview of your view
[view addSubview:simpleRatingControl];
[view addSubview:imagesRatingControl];
[view addSubview:coloredRatingControl];

StarRatingControl ScreenShot

ARC

StarRatingControl uses ARC.

License

StarRatingControl is available under the MIT license. See the LICENSE file for more info.

starratingcontrol's People

Contributors

xeniah avatar amseddi avatar kennethlj avatar jilouc avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.