Git Product home page Git Product logo

leestarrating's Introduction

LEEStarRating

简单易用的星星评分视图控件 支持整颗 , 半颗 , 无限制评分 可自定义分数范围和星星个数等.

演示

演示

特性

  • 支持三种评分类型 整颗 半颗 无限制.
  • 支持自定义星星数量以及间距.
  • 支持不同分数范围并自动计算当前分数
  • 支持点击评分 滑动评分.
  • 支持自定义图标.
  • 根据设置自适应控件高度.

用法

Objective-c

初始化并设置

        // 初始化并设置frame和个数
        
        LEEStarRating *ratingView = [[LEEStarRating alloc] initWithFrame:CGRectMake(15, 100, CGRectGetWidth(self.view.frame) - 30, 0) Count:10]; 
        
        ratingView.spacing = 10.0f; //间距
        
        ratingView.checkedImage = [UIImage imageNamed:@"star_orange"]; //选中图片
        
        ratingView.uncheckedImage = [UIImage imageNamed:@"star_gray"]; //未选中图片
        
        ratingView.type = RatingTypeWhole; //评分类型
        
        ratingView.touchEnabled = YES; //是否启用点击评分 如果纯为展示则不需要设置
        
        ratingView.slideEnabled = YES; //是否启用滑动评分 如果纯为展示则不需要设置
        
        ratingView.maximumScore = 10.0f; //最大分数
        
        ratingView.minimumScore = 0.0f; //最小分数
        
        [self.view addSubview:ratingView]; //添加到父视图
        

设置当前分数及回调

        // 当前分数变更事件回调
        
        ratingView.currentScoreChangeBlock = ^(CGFloat score){
            
            scoreLabel.text = [NSString stringWithFormat:@"%.1f" , score];
            
            NSLog(@"当前分数 [%.2f]" , score);
        };
        
        // 请在设置完成最大最小的分数后再设置当前分数 并确保当前分数在最大和最小分数之间
        
        ratingView.currentScore = 2.3f;

   

Swift

待更新

安装

手动安装

  1. 下载 LEEStarRating 文件夹内的所有内容。
  2. 将 LEEStarRating 内的源文件添加(拖放)到你的工程。
  3. 导入 LEEStarRating.h

系统要求

该控件最低支持 iOS 7.0Xcode 7.0 (其他未测)

许可证

LEEStarRating 使用 GPL V3 许可证,详情见 LICENSE 文件。

友情链接

一行代码搞定主题管理 - LEETheme

一行代码搞定Alert - LEEAlert

一行代码搞定ActionSheet - LEEActionSheet

个人主页

我的简书 我的博客

leestarrating's People

Contributors

lixiang1994 avatar

Watchers

James Cloos avatar 孔凡伍 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.