UIRating
使用 Swift 编写的可自定义评分视图。
特性
- 非常简单易实现。
- 拖动评分。
- 允许半星评分。
- 可自定义图标。
- 可自定义评分选项。
快速入门
UIRating
可以通过 Cocoa 依赖管理器 CocoaPods 进行安装。或者,您可以将 UIRating.swift
文件简单地复制到您的 Xcode 项目中。
# CocoaPods
pod "UIRating", "~> 1.0.1"
使用方法
示例文件夹中的示例项目提供了如何集成 UIRating
的例子,否则您可以按照以下步骤进行。
创建一个 UIRating 实例
let ratingView = UIRating()
给予所需的约束并设置代理
self.ratingView.delegate = self
完成
自定义
self.stackView.emptyIcon = UIImage(named: "example") //sets the icon for empty rating.
self.stackView.halfFullIcon = UIImage(named: "example") //sets the icon for half a rating.
self.stackView.fullIcon = UIIma(named: "example") //sets the icon for a full rating.
self.stackView.numberOfOptions = 7 //sets the number of rating options.
self.stackView.allowHalfSelections = true //enables selecting half a rating.
委托
extension ViewController: UIRatingDelegate {
func currentRating(rating: Double) {
print(rating)
}
}
文档
社区
- 发现一个错误?请打开一个工单。
- 有什么功能建议?请打开一个工单。
- 想要贡献吗?提交一个pull request。
资源
许可协议
UIVideoPlayer 可在 MIT 许可协议下使用,有关更多信息,请参阅LICENSE文件。