SwiftyStars is a star rating control for iOS written in Swift 5.0.
- Show a rating by setting the current rate
- Allow users to rate by tapping a star
- Haptic feedback generation upon taps
- Stars are fully customizable
- Control can be setup from Interface Builder, by passing a frame or by adding constraints via code
- iOS 11.0+
- Xcode 11+
You can use Cocoapods to install SwiftStars
by adding it to your Podfile:
pod SwiftyStars
- Storyboards: Drop a UIView and set its class to StarsView. The color, number of stars and spacing between stars can be adjusted from IB.
- Initiating an instance and passing a frame:
import StarsView
let starsView = StarsView(frame: .init(x: 0, y: 0, width: 200, height: 50)
starsView.numberOfStars = 5
starsView.starColor = .red
- Adding view using autlayout from code:
starsView.translatedAutoLayoutMasksToConstraints = false
NSLayouConstraing.activate([
starsView.topAnchor.constraint(equalTo: view.safeAreaLayout.topAnchor, constant: 20),
...
])