FUIRatingControl
@MainActor
open class FUIRatingControl : UIControl, Initializable, FUIAttributedStringDrawing
FUIRatingControl uses images to represent a rating.
The number of “On” images denotes the rating. The default ‘On’ image is a filled star, while the default ‘Off’ image is an unfilled star. The default ‘Half’ image is a half-filled star when the average rating’s decimal part is between 0.3 and 0.7, inclusive.
When the style property is .editable, user can tap an individual image to set the rating.
Users can also slide their finger from side to side over the control to select the rating.
The FUIRatingControl will send UIControl.Event.valueChanged event when rating changed.
An optional label displays the formatted average rating value to the left of the images, while another optional label displays the formatted rating value or review count to the right of the images.
Theming
Supported FUIRatingControl class paths:
fdlFUIRatingControl
Supported RatingControl properties:
on-color { -standard | -accented | -editable-disabled | -editable-disabled }: Color;
off-color { -standard | -accented | -editable-disabled | -editable-disabled }: Color;
half-color { -standard | -accented }: Color;
on-image { -standard | -editable }: Image;
off-image { -standard | -editable }: Image;
half-image { -standard | -editable }: Image;
Supported class paths:
fdlFUIRatingControl_leading_label
Supported properties::
font-color: Color
font-name: FontName
font-size: Number
font_style: UIFontTextStyle
font-color { -standard | -accented | -editable-disabled | -editable-disabled }: Color
font-name { -standard | -accented | -editable-disabled | -editable-disabled }: FontName
font-size { -standard | -accented | -editable-disabled | -editable-disabled }: Number
font-style { -standard | -accented | -editable-disabled | -editable-disabled }: UIFontTextStyle
Supported class paths:
fdlFUIRatingControl_trailing_label
Supported properties:
font-color: Color
font-name: FontName
font-size: Number
font_style: UIFontTextStyle
font-color { -standard | -accented | -editable-disabled | -editable-disabled }: Color
font-name { -standard | -accented | -editable-disabled | -editable-disabled }: FontName
font-size { -standard | -accented | -editable-disabled | -editable-disabled }: Number
font-style { -standard | -accented | -editable-disabled | -editable-disabled }: UIFontTextStyle
-
The available style for the
See moreFUIRatingControl.Declaration
Swift
public enum Style -
The style of this
FUIRatingControl.The default is
.editableDeclaration
Swift
@MainActor open var style: Style { get set } -
The range of the rating values.
The default is 0 through 5. This means that there will be 5 images. If rating is 0, all five images will be using the off image.
Declaration
Swift
@MainActor open var ratingBounds: ClosedRange<Int> { get set } -
The rating of this
FUIRatingControl.The default value is the lower bound of the
ratingBounds. less than the lower bound of theratingBounds.- Sets this value below the lower bound of the
ratingBoundsis interpreted as setting it to the lower bound of theratingBounds. - Sets this value over the upper bound of the
ratingBoundsis interpreted as setting it to the upper bound of theratingBounds.
Declaration
Swift
@MainActor open var rating: Int { get set } - Sets this value below the lower bound of the
-
The optional average rating value of this
FUIRatingControlcan display half-stars in both standard and accented styles. Theratingvalue is used when the average rating value is nil in these styles.“If the decimal part of the average rating value is between 0.3 and 0.7, inclusive, a half-star will be shown. For example, a rating of 0.6 will be rounded to 0.5, 0.2 will be rounded to 0, and 0.8 will be rounded to 1.
- Setting this value below the lower bound of
ratingBoundsis interpreted as setting it to the lower bound ofratingBounds.
Declaration
Swift
@MainActor open var averageRating: Float? { get set } - Setting this value below the lower bound of
-
Indicates whether to use a larger size for this control in
.standardor.accentedstyle.It is used to adjust the size of the image, the spacing of a control’s inner items (such as the space between the leading label and the first image, the space between images, and the space between the last image and the trailing label), and the font style for both the leading and trailing labels.“
The default value is determined by the style parameter. The default value is set to true when the
styleparameter is set to.editableor.editableDisabled, and false otherwise. For larger sizes, the space between the control’s items is 8, with an image size of 28 for.editableor.editableDisabledstyles, and 20 for.accentedor.standard. For other sizes, the space is 6 and the image size is 16.Declaration
Swift
@MainActor open var isLarge: Bool { get set } -
Indicates whether to display a label with the formatted average rating value to the left of the images. For the larger font sizes, if the content cannot fit on one line, the value will be displayed above the images.
The possible values for this label are:
- The formatted average rating value uses the default format “%.1f” when
leadingLabelFormatis nil for accented/standard styles. For example, 3.5. - The formatted rating value uses the default format “%d” when
leadingLabelFormatis nil and the optional average rating value is also nil for accented/standard styles. For example, ‘3.
By default, it was false.
Declaration
Swift
@MainActor open var showsLeadingLabel: Bool { get set } - The formatted average rating value uses the default format “%.1f” when
-
Indicates whether to display a label with the formatted review count or rating value to the right of the images. In larger font categories, if the content of the control cannot fit on one line, the value will be displayed below the images.
The possible values for this label are:
- The formatted review count value when
reviewCountis not nil or exceeds the review count ceiling value for standard/accent style. For example, ‘9 reviews’ or ‘8+ reviews.’ The default format ‘%d+ reviews’ is used when bothreviewCountandreviewCountCeilingare not nil andreviewCountexceedsreviewCountCeiling. In this case, ‘reviews’ is the localized term for ‘reviews,’ and the parameter is the value ofreviewCountCeiling. IfreviewCountCeilingis nil orreviewCountdoes not exceedreviewCountCeiling, the format ‘%d reviews’ is used instead, where ‘reviews’ is the localized term, and the parameter is the value ofreviewCount. - The formatted rating value with rating bounds count for editable/disabled styles. For example, ‘3 of 5,’ uses the default format ‘%d of %d,’ where “of” is the localized term for “of” when
trailingLabelFormatis nil. - When
reviewCountis nil andtrailingLabelFormatis not nil for standard/accent styles, the average rating value along with the rating bounds count is displayed usingtrailingLabelFormat. For instance, ‘3.5 of 5’ will be shown whentrailingLabelFormatis set to ‘%.1f of %d.’
By default, it was false.
Declaration
Swift
@MainActor open var showsTrailingLabel: Bool { get set } - The formatted review count value when
-
The optional review count of this
FUIRatingControl.It is used to display the review count information as the value of trailing label. For example, ‘9 reviews’
Declaration
Swift
@MainActor open var reviewCount: Int? { get set } -
The optional review count ceiling of this
FUIRatingControl.It is used to display the review count as the value of the trailing label when the value of
reviewCountexceeds the value ofreviewCountCeiling. For example, ‘100+ reviews’.Declaration
Swift
@MainActor open var reviewCountCeiling: Int? { get set } -
An optional formatter string used to format the value displayed to the left of the images. See
showsLeadingLabelfor more details.Declaration
Swift
@MainActor open var leadingLabelFormat: String? { get set } -
An optional formatter string used to format the value displayed to the right of the images. See
showsLeadingLabelfor more details.Declaration
Swift
@MainActor open var trailingLabelFormat: String? { get set } -
Indicates whether the rating items need to be wrapped
By default, it is false, and all the rating item images are displayed in one line
Declaration
Swift
@MainActor open var wrapsRatingItems: Bool -
The maximum number of image is shown in wrapped item row. When the
wrapsRatingItemsproperty is set totrue, the rating image items will automatically wrap to multiple lines. This property limits the maximum number of images per row. Remaining images will be displayed on the following lines.The default is
3. The value should between 1 to ratingBounds.count - 1Declaration
Swift
@MainActor open var maxItemsPerWrapRow: Int { get set } -
The custom image to be used for “On”.
If this property is not set, the default filled star image will be used.
Declaration
Swift
@MainActor open var onImage: UIImage? -
The custom image to be used for “Half”.
If this property is not set, the default half filled star image will be used.
Declaration
Swift
@MainActor open var halfImage: UIImage? -
The custom image to be used for “Off”.
If this property is not set, the default empty star image will be used.
Declaration
Swift
@MainActor open var offImage: UIImage? -
The custom fixed size of each item image view.
If this property is not set, the default size is used.
Declaration
Swift
@MainActor open var itemSize: CGSize? -
The custom spacing between item images.
If this property is not set, the default spacing is used.
- For styles
.standard.accented, the spacing is 6px. - For styles
.editableEnabledand.editableDisabled, the spacing is 8px.
Declaration
Swift
@MainActor open var interItemSpacing: CGFloat? - For styles
-
Default constructor.
Declaration
Swift
@MainActor public init(style: Style)Parameters
styleThe style for this
FUIRatingControl -
Convenience constructor.
This constructor is initialized with the
.editablestyle.Declaration
Swift
@MainActor required public convenience init() -
Sets the tintColor for specified range.
If developer did not set the tint colors, the default color will be used.
Declaration
Swift
@MainActor open func setTintColor(_ color: UIColor, for range: Range<Int>)Parameters
colorThe color to be applied to the item image for both on and off images.
rangeThe range for this color to be applied. Items out of bounds of the
ratingBoundswill be ignored. -
Undocumented
Declaration
Swift
@MainActor open override func systemLayoutSizeFitting(_ targetSize: CGSize, withHorizontalFittingPriority horizontalFittingPriority: UILayoutPriority, verticalFittingPriority: UILayoutPriority) -> CGSize
-
Declaration
Swift
@MainActor public var backingPropertyValueMap: [FUIPropertyRef : NSAttributedString?] -
Declaration
Swift
@MainActor public func setNeedsRefreshAttributedStrings() -
Declaration
Swift
@MainActor public func refreshAttributedStrings() -
Undocumented
Declaration
Swift
@MainActor public func setTintAttributes(_ attributes: [NSAttributedString.Key : Any], for property: FUIPropertyRef, state: Style) -
Undocumented
Declaration
Swift
@MainActor open func defaultAttributes(for property: FUIPropertyRef, state: Style) -> [NSAttributedStringKey : Any]
-
Undocumented
Declaration
Swift
@MainActor override public var keyCommands: [UIKeyCommand]? { get }
-
Undocumented
Declaration
Swift
@MainActor open override var accessibilityHint: String? { get set }