Coder Social home page Coder Social logo

yinjining / starrateview Goto Github PK

View Code? Open in Web Editor NEW
24.0 2.0 8.0 88 KB

swift五星评分,星星评分控件,支持自定义数量、拖拽、0.1颗星等多种操作

Home Page: http://www.jianshu.com/p/ea88987a7e87

Swift 100.00%
starview score swift star

starrateview's Introduction

JNStarRateView是封装好的一个星星评分控件

项目中用到好多星星评分,整理了一下给大家分享下 WechatIMG6.jpeg

我封装了一个类,以适应星星评分的各种情况。下面直接上代码

1、调用类使用

1.1 创建

//        let starView = JNStarRateView.init(frame: CGRect(x: 20,y: 60,width: 200,height: 38))//默认的是5颗星,分数为0分
let starView = JNStarRateView.init(frame: CGRect(x: 20,y: 60,width: 200,height: 38), numberOfStars: 5, currentStarCount: 3.4)
self.view.addSubview(starView)

1.2关闭用户手势操作,默认是开启的

starView.isUserInteractionEnabled = false//不支持用户手势操作

1.3支持滑动评分,默认只支持点击评分,不支持滑动评分

starView.userPanEnabled = true //滑动

1.4支持0.1颗星评分,默认整颗星

starView.integerStar = false // 完整星星

1.5滑动或点击后运动到手指位置所需时间

starView.followDuration = 0.1//滑动或点击后跟随到达时间,默认0.1秒

1.6当控件复用时,可修改当前星星数

starView.currentStarCount = 1 //当前显示的评星数

2、通过协议代理返回评分后的分数,别忘记了准守协议哦

starView.delegate = self


func starRate(view starRateView: JNStarRateView, score: Float) {
     print(score)
}

更详细的讲解请看http://www.jianshu.com/p/ea88987a7e87

starrateview's People

Contributors

yinjining avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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.