StarRatingControl 1.3.2

StarRatingControl 1.3.2

测试已测试
Lang语言 Obj-CObjective C
许可协议 MIT
发布最后发布2014年12月

未声明的拥有者维护。




  • 作者
  • xeniah
此项目是从amseddi/AMRatingControl分叉出来的。

StarRatingControl是一个类似于iPod应用程序中看到的“星级评分”的UI控件。

StarRatingControl允许您从0星开始选择任何数量的星。

您可以使用默认的星形符号,并自定义颜色或指定自定义图片。

入门方法

StarRatingControl.hStarRatingControl.m添加到您的项目中。

示例用法

    #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使用ARC。

许可协议

StarRatingControl在MIT许可下可用。有关更多信息,请参阅LICENSE文件。