欢迎光临
我们一直在努力

Swift写的评分控件

建站超值云服务器,限时71元/月

Swift写的评分控件

项目介绍:

SwiftyStarRatingView
https://github.com/Jerrrr/SwiftyStarRatingView

A simple star rating view written in pure swift, lightweight but powerful.

SwiftyStarRatingView 是一个用 swift 3.0 编写的评分控件,可以支持自定义图片和颜色,并且可以支持在XIB、StoreBoard中使用,并支持AutoLayout。

中文介绍

Screenshots



Requirements

  • iOS 8.0+

  • Xcode 8

  • Swift 3.0

CocoaPods

CocoaPods is the recommended way to add SwiftyStarRatingView to your project.

Add a pod entry for SwiftyStarRatingView to your Podfile.

    pod 'SwiftyStarRatingView'

Second, install SwiftyStarRatingView into your project:

    pod install

Manually

  1. Download the latest code version .

  2. Open your project in Xcode,drag the SwiftyStarRatingView folder into your project. Make sure to select Copy items when asked if you extracted the code archive outside of your project.

Usage

Create a simple rating view:

    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)

Setting this property to control whether to display a half stars:

    starRatingView.allowsHalfStars = true     //default is true
    starRatingView.value = 3.5                //default is 0

Whether accurate display:

    starRatingView.accurateHalfStars = true //default is true

Always callback or just stop touch:

    starRatingView.continuous = true        //default is true

Use custom image:

    starRatingView.halfStarImage = UIImage(named: "half.png")
    starRatingView.emptyStarImage = UIImage(named: "empty.png")
    starRatingView.filledStarImage = UIImage(named: "filled.png")

StoryBoard or XIB:

SwiftyStarRatingView also works great with Auto Layout, you can use it in StoryBoard or XIB.

Contacts

If you wish to contact me, email at: chen.developer@foxmail.com

Sina : @后知后觉乀

code4app

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » Swift写的评分控件
分享到: 更多 (0)