1 Star 0 Fork 0

Dog / StarRating

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

StarRating

CI Status Version License Platform

Example

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

说明简介
可以进行打分,或者进行分数展示,这个视图可以打0分
属性说明:
horizontalSpacing: 设置展示的图片(例如星星图片)之间的水平距离
highlightImage , unHightlightImage: 设置得到分数的时候显示的图片(默认彩色星星图片),没有得到分数时候显示的图片(默认灰色星星图片)
aspectRatio: 显示分数图片的高宽比,宽度是与视图的宽度与图片间隙决定的,如果我们用到的宽高比不是1:1,那么需要使用这个参数设置一下,防止图片拉伸
isAllowedSliding: 是否允许滑动打分,如果不允许只能打整数的分数例如:1分,2分,3分...,不能打1.2分等
currentValue: 当前需要展示的分数,如果有5颗星,那么这里的值范围0~5,如果设置为-1,那么为0,如果设置为9那么为5,我们可以关闭用户交互的方法,只让展示设置的分数,而不能够通过点击滑动的方式引起展示的分数发生改变(userInteractionEnabled设置为 NO 关闭交互)
starNum: 星星的个数,这里每一个颗星,代表1分,storyboard 中初始化默认我5颗星
currentValueBlock: 实时展示动态展示当前分数值 

使用方法:
    1: storyboard 中使用
    如果想修改属性,只能在- (void)viewDidLayoutSubviews方法中设置, viewDidLoad 中首次设置无法正常显示例如:
    
        - (void)viewDidLayoutSubviews {
        
            // self.star1 是 StarEvaluatorView 类 
            self.star1.horizontalSpacing = 20;

            // 注意:
               这里不能对星星进行打分,因为这个方法只要视图发生变化,都会执行,并不是仅仅执行一次,如果需要展示分数,并且是动态展示分数, 例如:self.satr1.currentValue = 3,可以在 viewDidLoad 方法中调用设置首次展示的分数值,这里除了 currentValue , 交互属性, 是否允许滑动, 属性其他的属性都可以调用
        } 
    2: init 初始化
        StarEvaluatorView *star = [[StarEvaluatorView alloc] initWithFrame:CGRectMake(50, 150, [UIScreen mainScreen].bounds.size.width - 100, 50) withNumberOfStar:4];
        star.currentValueBlock = ^(CGFloat currentValue) {

            dispatch_async(dispatch_get_main_queue(), ^{

                // 这里可以在我们展示分数的 label 上赋值展示
            });
        };
        // 这里不设置默认为0,也就是星星的宽度为视图宽度的1/4
        star.horizontalSpacing = 20;
        star.aspectRatio = 2; // 这里的意思是高度是宽度1.2倍,这里的比例要根据提供的图片决定
        [self.view addSubview:star];

Requirements

Installation

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

pod "StarRating"

Author

li625317534, 625317534@qq.com

License

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

Copyright (c) 2017 li3299838665 <625317534@qq.com> Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

简介: 一个打分视图 功能: 可以点击打分,滑动打分,通过赋值展示分数 展开 收起
Objective-C
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
Objective-C
1
https://gitee.com/6253175234/starrating.git
git@gitee.com:6253175234/starrating.git
6253175234
starrating
StarRating
master

搜索帮助