IOS 五星评分控件

程序中需要打分的功能,在网上找了几个,都不是很满意。下面是实现出的效果。可以点击,可以拖动。

使用方法:初始化控件。

    TQStarRatingView *starRatingView = [[TQStarRatingView alloc] initWithFrame:CGRectMake(0, 300, 50 * 5, 50) numberOfStar:5];
    starRatingView.delegate = self;
    [self.view addSubview:starRatingView];

实现一个委托函数

-(void)starRatingView:(TQStarRatingView *)view score:(float)score
{
    self.scoreLabel.text = [NSString stringWithFormat:@"%0.2f",score * 10 ];
}

因为项目暂时不需要。这里没有写用代码设置星星显示位置的方法,以后有时间会补上。

控件的源代码放在 https://github.com/TinyQ/TQStarRatingView 上了。有需要可以去下载下。

原文地址:https://www.cnblogs.com/CCSSPP/p/3297639.html