CXStarRatingView
Feature
- 支持手动布局和自动布局
- 支持点击和滑动手势
- 支持半星、整星、任意星
Example
let starView = CXStarRatingView.init(forgroundStarImage: UIImage(named: "star_red"),
backgroundStarImage: UIImage(named: "star_gray"),
style: .whole)
starView.translatesAutoresizingMaskIntoConstraints = false
starView.currentStarValue = 3.5
starView.currentValueDidChangeBlock = { value in
print(value)
}
view.addSubview(starView)
NSLayoutConstraint.activate([
starView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
starView.topAnchor.constraint(equalTo: view.topAnchor, constant: 200),
starView.widthAnchor.constraint(equalToConstant: 200),
starView.heightAnchor.constraint(equalToConstant: 40)
])
Requirements
iOS9 or later
Installation
CXStarRatingView is available through CocoaPods. To install it, simply add the following line to your Podfile:
target 'Project' do
pod 'CXStarRatingView'
end
Author
License
CXStarRatingView is available under the MIT license. See the LICENSE file for more info.