BPKStarRating

@interface BPKStarRating : UIView

A component for displaying a star rating for example for reviews.

The component uses a scale of 0 to 5 stars. It supports half stars and will round down to the nearest half star for display. When using the stars to show an average of many ratings it’s advisable to display a text string adjecent to the star rating with the exact rating value.

  • Rating value the star rating view will displaying by rounding the value to full and half stars between 0.0 and 5.0. Example 1: setting 4.3 to rating will render 4.0 stars. 5 stars where the first 4 of them are filled with BPKThemeDefinition.starFilledColor and the last star is not filled. Example 2: setting 4.6 to rating will render 4.5 stars. 5 stars where the first 4 of them are filled with BPKThemeDefinition.starFilledColor and the last star is half filled with the same color. Set this property to render new rating. The default value is 0.0, in case of setting a value smaller than 0.0 or greater than 5.0 the view will show 0.0 or 5.0.

    Declaration

    Objective-C

    @property (nonatomic) float rating;

    Swift

    var rating: Float { get set }
  • Size of the stars, its default value is BPKStarSizeSmall. Setting updates the displayed stars.

    See

    BPKStarSize

    Declaration

    Objective-C

    @property (nonatomic) BPKStarSize size;

    Swift

    var size: BPKStarSize { get set }
  • Creates a BPKStarRating with a decoder (typically when creating from Storyboards)

    Declaration

    Objective-C

    - (nullable instancetype)initWithCoder:(nonnull NSCoder *)aDecoder;

    Swift

    init?(coder aDecoder: NSCoder)

    Parameters

    aDecoder

    Decoder object to extract parameters from

    Return Value

    BPKStarRating instance.

  • Create a BPKStarRating with a given frame.

    Declaration

    Objective-C

    - (nonnull instancetype)initWithFrame:(CGRect)frame;

    Swift

    init(frame: CGRect)

    Parameters

    frame

    The initial frame of the star rating.

    Return Value

    BPKStarRating instance.