Code Monkey home page Code Monkey logo

floatratingview's Introduction

FloatRatingView

A simple rating view for iOS written in Swift! Supports whole, half or floating point values. I couldn't find anything that easily set floating point ratings, so I made this control based on a Ray Wenderlich tutorial. Some of the best iOS tutorials that I've come across.

Check out the post on medium for a full write-up.
https://medium.com/@glenyi/float-rating-view-in-swift-e740b6b9404d

FloatRatingView Demo

Usage

Initialize from a nib/xib or programmatically. Set the empty and full image, then you're pretty much good to go! Check out the demo app to see how it can be used.

Release v4.0 is updated for Swift 5.0 while v1.0.3 is on Swift 2.3.

Usage in an Objective-C Project

  1. Import the Swift File
  2. Ensure the build settings in your project are set to enable Swift usage (see here and here)
  3. import "YOUR_PROJECT_NAME-Swift.h" in your Objective-C files where you want to use FloatRatingView

Pod Installation

For Swift 2.3 projects just add the following to your podfile:

pod 'FloatRatingView', '~> 1.0.3'

For Swift 5.0 projects:

pod 'FloatRatingView', '~> 4'

How it works

The concept is a little different from the source tutorial. The float rating view lays the full image views on top of the empty image views then sets the CALayer mask property to partially hide full images. The full image view mask frame is calculated whenever needed for half or floating point values.

floatratingview's People

Contributors

apbendi avatar chronos92 avatar glenyi avatar marcelofabri avatar mikeger avatar romk1n avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

floatratingview's Issues

Add tvOS to the podspec?

I'm trying to fix up PopcornTimeTV/PopcornTimeTV, and apparently they've been using this pod in the tvOS target in the past. Not sure how since it appears your podpsec never declared it supported tvOS. It looks like they just created their own spec and manually added tvOS to the spec.

This leads me to believe it actually works on tvOS. Could you add tvOS to the list of supported platforms, like the spec file linked above does? Worst case, it doesn't work and you can remove it. Best case, it does, and I'll let you know!

No shared framework scheme for Carthage

When trying to do a carthage update, receiving the following error:

Dependency "FloatRatingView" has no shared framework schemes for any of the platforms: iOS

Improve touch UX.

If you slide your finger out of the vertical bounds of the image views while using fractional stars, the stars will only jump by whole numbers.

This can be fixed by changing the check in updateLocation.

  • Replace imageView.point(inside: newLocation, with: nil) with newLocation.x < imageView.frame.width.

This will keep the focus on the movement along the x-axis and ignore the y-axis, which allows more a much better user experience.

Delegate not @IBOutlet

It would be convenient if the delegate of the rating view could be set in the storyboard.

Not support in Swift 3.0

Hello ,

I have tried to implement in my application which is in Swift 3.0 but unfortunately this is not work in my app. It gives me error like this
"FloatRatingView is not a member class of FloatRatingView"

Thanks.

Remove rating

There need an option, if people select an already selected star or swipes outside the first star it removes

Integration with RxSwift

How can I integrate this with an RxSwift project? I am trying to bind the FloatViewRating.rating value to an RxSwift variable in the model.

Backend

Hi strekfus.

Congrats, awesome code.

Do you think would be nice to have this code connected to Parse backend ? For example for a user to rate some recipe/movie/song or whatever and other users to see it ?

Would you be interested in upgrade this example to be connected to Parse ? Or give any code suggestion on how to link it to Parse...

Thnx and cheers!

Version 4.0 released

Version 4.0 ๐Ÿ†•

I've updated current project and forked to a new repository, because that repository is not maintained anymore ๐Ÿ™ (great work, glenyi, thank you for creating that project).

New version is located here: https://github.com/Sorix/RatingControl.

Changelog

UIControl

FloatingRatingView renamed to RatingControl. Also now it is a subclass of UIControl instead of UIView, because that RatingView is closer to control type than view type.

Now control supports default UIControl methods, like isEnabled, addAction, @IBAction outlets and so on. Please use it instead of delegate methods, because it's a more native way.

Storyboard

You can add storyboard's @IBAction outlets in Interface Builder without writing a code for delegate methods. Less code for you.

Also I've added support for intrinsicContentSize, so view know about own's desired size (like labels or buttons) and you will need to define less constraints and it will be easier to configure it in Interface Builder.

Haptic

Support of haptic feedback was added, try that magic on devices with appropriate hardware.

Compatibility

RatingControl (4.0) is almost compatible with previous version of FloatingRatingView.

  1. You need to find and replace import statements because of library renaming:
import FloatingRatingView // search that
import RatingControl // replace to that
  1. Minimum required iOS version now is 10.0.

Because of that 2 breaking changes, version was changed to 4.0.

RatingControl is now a subclass of UIControl that's why a lot of old methods was deprecated, you still can use it. XCode will warn you about outdated methods with help messages with fix proposals.

Other changes

  • Support Swift 4.2
  • Objective-C support
  • Update Example application
  • Tidy folder structure

No suitable image found

Hi everybody.

I have an error when I tried to start my app in an Iphone 7 plus with IOS 13.3.1, but in an others Iphone with a IOS oldest it is working fine, it is the error that I have obtain:

dyld: Library not loaded: @rpath/FloatRatingView.framework/FloatRatingView
Referenced from: /private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Kafuu
Reason: no suitable image found. Did find:
/private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Frameworks/FloatRatingView.framework/FloatRatingView: code signature invalid for '/private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Frameworks/FloatRatingView.framework/FloatRatingView'

/private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Frameworks/FloatRatingView.framework/FloatRatingView: code signature invalid for '/private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Frameworks/FloatRatingView.framework/FloatRatingView'

/private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Frameworks/FloatRatingView.framework/FloatRatingView: stat() failed with errno=1
/private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Frameworks/FloatRatingView.framework/FloatRatingView: code signature invalid for '/private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Frameworks/FloatRatingView.framework/FloatRatingView'

/private/var/containers/Bundle/Application/C1FE3C2D-55F9-4A68-B182-26C43EDA4B98/Kafuu.app/Frameworks/FloatRatingView.framework/FloatRatingView: stat() failed with errno=1

(lldb)

Regards

ISSUE With swift 1.2

I have some issues with the interface builder.
So XCODE tells me :
/Main.storyboard: warning: IB Designables: Ignoring user defined runtime attribute for key path "rating" on instance of "UIView". Hit an exception when attempting to set its value: [<UIView 0x7fc0b9cab4d0> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key rating.

... not key value coding-compliant for the key ...

I am getting a bunch of warnings of the following type:

Ignoring user defined runtime attribute for key path [variable name] of instance of UIView. Hit an exception when attempting to set its value ...setValue:forUndefinedKey: this class is not key value coding compliant for the key [variable name]

I see this for editable, emptyImage, floatRatings, fullImage, halfRatings and so on.

I have inserted a view controller to storyboard which has a view with custom class FloatRatingView.

I believe that I started to see it after changing the deployment target to iOS7. I have already searched the web, but I did not find a fast solution. I am happy to help if I understand the issue.

Rendering issue

I just got this error whenever i am enter in storyboard...after some time it disappears...but it gives slow performance error...how to get rid of this

    error: IB Designables: Failed to render instance of FloatRatingView: Rendering the view took longer than 200 ms. Your drawing code may suffer from slow performance.

Spacing

how can you increase the spacing between the stars? My stars are all touching edge to edge.

floatRatingView:isUpdating: should be optional

I like this FloatRatingView! However I feel floatRatingView:isUpdating: should be optional since not everyone would like to know value while it is updating but currently to conform to protocol one needs to add that method no matter what.

No support for RTL

My app is in Arabic but the ratingview is still in LTR. Please help me asap how can I solve this problem.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.