Skip to content

swift电商五星评价,星星评分控件,支持自定义数量、拖拽、间隔、设置最小星星数等操作

Notifications You must be signed in to change notification settings

chenjie1219/StarRate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift Carthage Compatible Platform

StarRate

主要内容的介绍

  • 进行评分(支持点击,滑动,最少星星数设置)

  • 展示评分

  • 类型选择(整颗星,半颗星,部分星星)

Requirements

  • Swift 5.0
  • iOS 9.0.0+
  • Xcode 10.2

Installation

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

To integrate StarRate into your Xcode project using Carthage, specify it in your Cartfile:

github "chenjie1219/StarRate"

Run carthage update to build the framework and drag the built StarRateView.framework into your Xcode project.

Manually

Just download the project, and drag and drop the "StarRateView" folder in your project.


Usage

1.创建星级视图(可进行评分)

/// 创建视图对象(totalStarCount:总星星数量, currentStarCount:当前星星数, starSpace:星星的间隔)
let starView = StarRateView(frame: CGRect(x: 0, y: 0, width: 120, height: 20),totalStarCount: 5 ,currentStarCount: 0 ,starSpace: 5)

/// 显示星级视图(type:星星类型, isPanEnable:是否可滑动评分, leastStar:评分的最少星星数) 
starView.show(type: .default, isPanEnable: true, leastStar: 0) { (score) in
    /// 评分后的回调方法
    <#code#>
}

2.创建星级视图(不可评分,仅展示当前评分)

/// 创建视图对象(totalStarCount:总星星数量, currentStarCount:当前星星数, starSpace:星星的间隔)
let starView = StarRateView(frame: CGRect(x: 0, y: 0, width: 120, height: 20),totalStarCount: 5 ,currentStarCount: 3 ,starSpace: 5)

/// 关闭用户手势操作,默认是开启的(关闭后不可点击,不可滑动,仅用来显示当前评分)
starView.isUserInteractionEnabled = false//不支持用户手势操作

效果图

1

Author

About

swift电商五星评价,星星评分控件,支持自定义数量、拖拽、间隔、设置最小星星数等操作

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published