Latest 0.2.0
Homepage https://github.com/0jun0815/YJStarRatingView
License MIT
Platforms ios 10.0
Authors

Custom rating view.

This is a rating view that represent value with five stars. When you set a maximum value, this is internally calculates and displays the value. Three images(full, half, empty) are required to create this. This source is based on Medium tutorial and Raywenderlich tutorial.

 

YJStarRatingView

 

Usage

Programmatic

Initializers:

  • required init(frame: CGRect, type: RatingType = .half, isEditable: Bool = true)
  • convenience init(frame: CGRect, type: RatingType, isEditable: Bool, minRating: Int, maxRating: Int, currentRating: Double)

properties:

  • var delegate: YJStarRatingViewDelegate?
    • It is possible to process before, during, and after the value change.
  • var emptyImage: UIImage?
    • Empty image. required
  • var fullImage: UIImage?
    • Full image. required
  • var halfImage: UIImage?
    • Half image. required
  • var maxRating: Int
    • Max rating. default value is 5.
  • var minRating: Int
    • Min rating. default value is 0.
  • var currentRating: Double
    • Current rating. default value is 0.
  • var type: RatingType
    • The rating type are full, half, float.
    • var isEditable: Bool
    • If true, the user interaction enabled. If false only viewing allowed.

Example:

let starRatingView = YJStarRatingView(frame: frame)
starRatingView.emptyImage = UIImage(named: "ic_star_large")
starRatingView.fullImage = UIImage(named: "ic_star_large_full")
starRatingView.halfImage = UIImage(named: "ic_star_large_half")
view.addSubview(starRatingView)

 
YJStarRatingView

Storyboard

Add a view and register the class:

YJStarRatingView
 

Assign a value to the properties:

YJStarRatingView

 

Installation

CocoaPods

To integrate YJStarRatingView into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '10.0'
use_frameworks!

target '<Your Target Name>' do
pod 'YJStarRatingView', '~> 0.2.0'
end

Then, run the following command:

$ pod install

 
 

by. 0junChoi email: [email protected]

Latest podspec

{
    "name": "YJStarRatingView",
    "version": "0.2.0",
    "summary": "Create a custom rating view.",
    "description": "TODO: Add long description of the pod here.",
    "homepage": "https://github.com/0jun0815/YJStarRatingView",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Young Jun Choi": "[email protected]"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source": {
        "git": "https://github.com/0jun0815/YJStarRatingView.git",
        "tag": "0.2.0"
    },
    "source_files": "YJStarRatingView/Sources/*.swift",
    "swift_version": "4.0"
}

Pin It on Pinterest

Share This