The AARatingBar is a customizable and easy-to-use rating bar for iOS applications. It provides a simple way to add a rating bar with a specified number of stars to your app and allows users to select a rating value.
Features
- Customizable appearance to match your app’s design
- Allows users to select a rating value
- Supports half-star ratings
- Easy to integrate into your iOS project
- Compatible with both Objective-C and Swift
Installation
CocoaPods
To integrate AARatingBar into your project using CocoaPods, add the following line to your Podfile
:
pod 'AARatingBar'
Then, run the following command:
$ pod install
Manual
- Download the latest version of AARatingBar from the GitHub repository.
- Drag and drop the
AARatingBar
folder into your Xcode project.
Usage
Objective-C
Import the header file:
#import "AARatingBar.h"
Create an instance of AARatingBar:
AARatingBar *ratingBar = [[AARatingBar alloc] initWithFrame:CGRectMake(0, 0, 200, 40)];
Add it to your view:
[self.view addSubview:ratingBar];
Swift
Import the module:
import AARatingBar
Create an instance of AARatingBar:
let ratingBar = AARatingBar(frame: CGRect(x: 0, y: 0, width: 200, height: 40))
Add it to your view:
self.view.addSubview(ratingBar)
Customization
The AARatingBar provides several properties and methods for customization:
Properties
rating
: The current rating value of the bar.maximumRating
: The maximum rating value.minimumRating
: The minimum rating value.allowsHalfStars
: Flag to allow half-star ratings.emptyStarImage
: The image to be displayed for empty stars.filledStarImage
: The image to be displayed for filled stars.
Methods
setRating(_:animated:)
: Set the rating value programmatically.getRating()
: Get the current rating value.
Example
Here’s an example of how to use AARatingBar:
AARatingBar *ratingBar = [[AARatingBar alloc] initWithFrame:CGRectMake(0, 0, 200, 40)];
ratingBar.maximumRating = 5;
ratingBar.rating = 3.5;
ratingBar.allowsHalfStars = YES;
[self.view addSubview:ratingBar];