Coder Social home page Coder Social logo

ywb3930 / grstarsview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from assuner-lee/grstarsview

0.0 0.0 0.0 42 KB

一个简单实用的iOS 星星评分view,支持小数,支持点击、拖动评分。

License: MIT License

Objective-C 43.86% Ruby 5.30% Shell 50.83%

grstarsview's Introduction

GRStarsView

CI Status Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

GRStarsView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "GRStarsView"

先看效果

使用

1. 初始化一个GRStarsView

GRStarsView *starsView = [[GRStarsView alloc] initWithStarSize:CGSizeMake(30, 30) margin:10 numberOfStars:5];

初始化了星星的尺寸,间距和个数; 此时starsView的默认origin为(0, 0),size已设置好;

*2. 设置frame ,并添加到某一个视图上

starsView.frame = CGRectMake(50, 100, starsView.frame.size.width, starsView.frame.size.height);
[view addSubview:starsView]; //view为某个视图

3. 配置属性(可否点击、拖动评分,是否允许小数显示)

 starsView.allowSelect = YES;  // 默认可点击
 starsView.allowDecimal = YES;  //默认可显示小数
 starsView.allowDragSelect = NO;//默认不可拖动评分,可拖动下需可点击才有效

4. 配置触摸(点击,拖动)结束 score改变后的block回调

starsView.touchedActionBlock = ^(CGFloat score) {
        infoLabel.text = [NSString stringWithFormat:@" 分数: %.1f", score];

其中,默认返回的score精确到两位。

*设置score,可绘出星星评分

starsView.score = 4.5;

(若在此之前设置了回调block,会触发一次回调)

谢谢观看,如有错误,请多指正。

Author

Assuner-Lee, [email protected]

License

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

grstarsview's People

Contributors

assuner-lee 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.