Latest 0.1.0
Homepage https://github.com/Assuner-Lee/GRStarsView
License MIT
Platforms ios 8.0
Authors

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.

Latest podspec

{
    "name": "GRStarsView",
    "version": "0.1.0",
    "summary": "u4e00u4e2au7b80u5355u5b9eu7528u7684iOS u661fu661fu8bc4u5206viewuff0cu652fu6301u5c0fu6570uff0cu652fu6301u70b9u51fbu3001u62d6u52a8u8bc4u5206u3002",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/Assuner-Lee/GRStarsView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Assuner-Lee": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Assuner-Lee/GRStarsView.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "GRStarsView/Classes/**/*",
    "resource_bundles": {
        "GRStarsView": [
            "GRStarsView/Assets/*.png"
        ]
    }
}

Pin It on Pinterest

Share This