A customizable rating View written in Swift.
- Super easy and simple to implement.
- Drag through to rate.
- Allow half rating.
- Customizable icons.
- Customizable option to rate from.
UIRating
is available for installation using the Cocoa dependency manager CocoaPods. Alternatively, you can simply copy the UIRating.swift
file into your Xcode project.
# CocoaPods
pod "UIRating", "~> 1.0"
The sample project in the example folder provides an example of how to integrate UIRating
, otherwise you can follow these steps.
Create an instance of UIRating:
let ratingView = UIRating()
Give the desired constraints and set the delegate:
self.ratingView.delegate = self
DONE!
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 = UIImage(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.
self.stackView.spacing = 10 //sets the spacing between each rating icon.
extension ViewController: UIRatingDelegate {
func currentRating(rating: Double) {
print(rating)
}
}
You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.
- Found a bug? Open an issue.
- Feature idea? Open an issue.
- Want to contribute? Submit a pull request.
UIRating is available under the MIT license, see the LICENSE file for more information.