https://github.com/magi82/mgstarratingview
MGStarRatingView is a view for rating.
https://github.com/magi82/mgstarratingview
rating star swift
Last synced: 6 months ago
JSON representation
MGStarRatingView is a view for rating.
- Host: GitHub
- URL: https://github.com/magi82/mgstarratingview
- Owner: magi82
- License: mit
- Created: 2017-05-26T09:11:57.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-03-01T19:02:02.000Z (over 2 years ago)
- Last Synced: 2025-03-25T06:40:35.449Z (6 months ago)
- Topics: rating, star, swift
- Language: Swift
- Homepage: https://magi82.github.io
- Size: 1.18 MB
- Stars: 78
- Watchers: 4
- Forks: 15
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MGStarRatingView

[](http://cocoapods.org/pods/MGStarRatingView)
[](http://cocoapods.org/pods/MGStarRatingView)
[](https://github.com/Carthage/Carthage)
[](https://travis-ci.org/magi82/MGStarRatingView)
[](http://cocoapods.org/pods/MGStarRatingView)MGStarRatingView is a view for rating.
Simple and easy to implement. :sunny:It supports programmatically and xib.
No image is required. Just choose color.## Sample
## Usage (Programmatically)
- Creating and Implementing a View```swift
let starView = StarRatingView()
let attribute = StarRatingAttribute(type: .rate,
point: 30,
spacing: 10,
emptyColor: .red,
fillColor: .blue,
emptyImage: nil,
fillImage: nil)
starView.configure(attribute, current: 0, max: 5)
starView.delegate = self
self.view.addSubview(starView)
```- Delegate implementation
```swift
func StarRatingValueChanged(view: StarRatingView, value: CGFloat) {
// use value
}
```## Usage (xib)
First, add `UIView`.
Register Custom Class as `StarRatingView` and register Module as `MGStarRatingView`.*Please be careful.*
If you type the spelling of `Type String` wrongly, it will be applied as the default type.
The default type is `rate`.
![]()
![]()
## API Reference
```swift
// A delegate for receiving values.
public weak var delegate: StarRatingDelegate?// A type that represents a value.
// There are three kinds. (rate, half, fill)
public var type: StarRatingType// The current value.
public var current: CGFloat// The maximum number of stars.
public var max: Int// The spacing between stars.
public var spacing: CGFloat// The size of the star.
// The horizontal and vertical sizes are the same.
public var point: CGFloat// The color value of the empty star.
public var emptyColor: UIColor// The color value of the full star.
public var fillColor: UIColor// The image object of the empty star.
var emptyImage: UIImage?// The image object of the full star.
var fillImage: UIImage?
```## Aid
- [taewan0530](https://github.com/taewan0530)
## Requirements
- Swift 4.0+
- iOS 8.0+## Installation
- **For iOS 8+ projects** with [CocoaPods](https://cocoapods.org):
```ruby
pod 'MGStarRatingView', '~> 1.0.0'
```- **For iOS 8+ projects** with [Carthage](https://github.com/Carthage/Carthage):
```ruby
github "magi82/MGStarRatingView" ~> 1.0.0
```## Author
magi82, bkhwang82@gmail.com
## License
**MGStarRatingView** is available under the MIT license. See the [LICENSE](LICENSE) file for more info.