An emoji-liked rating view for iOS, implemented in Swift3.
Android version: PeterSmileRate by SilicorniO. Great work ! :)
Inspired by Rating Version A - Hoang Nguyen
Blog
土土哥的技术Blog - Swift开源项目: TTGEmojiRate的实现
- More interactive with Emoji and drag gesture.
- Highly customizable.
- Can be used in Interface Builder.
TTGEmojiRate is an emoji-liked rating view for iOS which is implemented in Swift.
You can drop up and down on the Emoji face to change the rate, which is more interactive.
TTGEmojiRate is also highly customizable that many features of it can be configure, like the emoji line width and the mouth width.
- Create an instance of EmojiRateView and add it to the parent view.
let rateView = EmojiRateView.init(frame: CGRectMake(0, 0, 200, 200))
rateView.center = self.view.center
self.view.addSubview(rateView)
- Drop a view in the Interface builder and set the
Custom Class
toEmojiRateView
To run the example project, clone the repo, and run pod install
from the Example directory first.
Swift3.
Xcode8.
iOS 8 and later.
You can use CocoaPods to install TTGEmojiRate
by adding it to your Podfile
:
pod "TTGEmojiRate"
You can use Carthage to install TTGEmojiRate
by adding it to your Cartfile
:
github "zekunyan/TTGEmojiRate"
rateValueChangeCallback: ((newRateValue: Float) -> Void)?
defines the callback closure when rateValue
changes.
emojiRateView.rateValueChangeCallback = {(rateValue: Float) -> Void in
NSLog("The new rate value is: \(rateValue)")
}
rateColorRange: (from: UIColor, to: UIColor)
When rateValue
changes from 0 to 5, the rateColor
will change from the from: UIColor
to to: UIColor
.
emojiRateView.rateColorRange = (
UIColor.redColor(),
UIColor.greenColor()
)
rateDragSensitivity: CGFloat
defines the sensitivity when drag to change rateValue.
zekunyan, [email protected]
TTGEmojiRate is available under the MIT license. See the LICENSE file for more info.