- iOS 12.0+
- Xcode 15+
- Swift 5.0+
Recommended: add the package in Xcode: File → Add Package Dependencies… and use:
https://github.com/Jerrrr/SwiftyStarRatingView.git
Use Up to Next Major from 2.0.1 (or pin an exact tag) so updates stay semver-safe.
If you declare dependencies in a Package.swift:
.package(url: "https://github.com/Jerrrr/SwiftyStarRatingView.git", from: "2.0.1")Then add SwiftyStarRatingView to the appropriate target’s dependencies and import:
import SwiftyStarRatingViewYou can also integrate via CocoaPods (published pod version follows Git tags, e.g. 2.0.1).
Add a pod entry for SwiftyStarRatingView to your Podfile.
pod 'SwiftyStarRatingView'
Second, install SwiftyStarRatingView into your project:
pod install
Carthage is not actively validated in CI anymore; Swift Package Manager (above) is the recommended integration path. If you still rely on Carthage, you may try:
github "jerrrr/SwiftyStarRatingView"
Pin a tag in the Cartfile if your workflow requires reproducible builds.
- Download the latest code version .
- Open your project in Xcode,drag the
SwiftyStarRatingViewfolder into your project. Make sure to select Copy items when asked if you extracted the code archive outside of your project.
let starRatingView = SwiftyStarRatingView()
starRatingView.frame = CGRect(x: x, y: y, width: width, height: height)
starRatingView.maximumValue = 5 //default is 5
starRatingView.minimumValue = 0 //default is 0
starRatingView.value = 3 //default is 0
starRatingView.tintColor = UIColor.yellow
starRatingView.addTarget(self, action: #selector(function), for: .valueChanged)
self.view.addSubview(starRatingView)
starRatingView.allowsHalfStars = true //default is true
starRatingView.value = 3.5 //default is 0
starRatingView.accurateHalfStars = true //default is true
starRatingView.continuous = true //default is true
starRatingView.halfStarImage = UIImage(named: "half.png")
starRatingView.emptyStarImage = UIImage(named: "empty.png")
starRatingView.filledStarImage = UIImage(named: "filled.png")
SwiftyStarRatingView also works great with Auto Layout, you can use it in StoryBoard or XIB.
If you wish to contact me, email at: hello@jerrrr.com
Sina : @后知后觉乀
SwiftyStarRatingView is released under the GNU GENERAL PUBLIC LICENSE. See LICENSE for details.




