Is there any controls available for star rating?

2019-03-17 22:09发布

Is there any controls available for star rating in ios ? So i can use that in UITableviewCell ??

I know there are some open open source controls like DYRating etc.. But iam not able to add it in tableview cell .

11条回答
爷的心禁止访问
2楼-- · 2019-03-17 22:19

Swift3

https://github.com/marketplacer/Cosmos

  • install pod

    target 'TargetName' do

    pod 'Cosmos'

  • Install pod file with this command pod install

  • Put a simple UIView in your storyboard and give the class name as CosmosView and Module name Cosmos

enter image description here

HERE YOU CAN ACCESS THE ATTRIBUTES

enter image description here

查看更多
神经病院院长
3楼-- · 2019-03-17 22:19

Yeah there are many libraries which you can use to make such controls like cosmos Cosmos library for rating control

if you want something like that looks like rating graph (like the one in image)then you can see this repo in github Rating graph view in iOS

enter image description here

查看更多
冷血范
5楼-- · 2019-03-17 22:24

Use https://github.com/hugocampossousa/HCSStarRatingView. it easy to implement this. just write down these lines of code. Create IBOutlet HCSStarRatingView for in .h file an create one string for storing the rating value.

@property (weak, nonatomic) IBOutlet HCSStarRatingView *starRatingView;
@property (weak, nonatomic) NSString *ratingStr;

in .m file write down these lines

self.starRatingView.maximumValue = 5;
self.starRatingView.minimumValue = 0;
self.starRatingView.value = 0;
self.starRatingView.tintColor = [UIColor yellowColor];
self.starRatingView.allowsHalfStars = YES;
self.starRatingView.emptyStarImage = [[UIImage imageNamed:@"heart-empty"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
self.starRatingView.filledStarImage = [[UIImage imageNamed:@"heart-full"] imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate];
[self.starRatingView addTarget:self action:@selector(didChangeValue:) forControlEvents:UIControlEventValueChanged];

- (IBAction)didChangeValue:(HCSStarRatingView *)sender {
   NSLog(@"Changed rating to %.1f", sender.value);
  ratingStr = [NSString stringWithFormat:@"%.1f",sender.value];
  if([hostRatingStr isEqualToString:@"-0.0"]){
      self.ratingLbl.text = @"0.0";
  }else{
      self.ratingLbl.text = hostRatingStr;
   }
 }
查看更多
Bombasti
6楼-- · 2019-03-17 22:26

Use https://github.com/shantaramk/RatingView.

It effortless to implement this. just follow below steps:

Set Star View IBOutlet

    @IBOutlet weak var rateView: StarRateView!

Prepare Star Rate View

func setupStarRateView() {
    self.rateView.delegate = self
    self.rateView.maxCount = 5
    self.rateView.fillImage = UIImage(named: "fill_star")!
    self.rateView.emptyImage = UIImage(named: "empty_star")!
}

Adopt Rate View Delegate

extension RateServiceViewController: RatingViewDelegate {

func updateRatingFormatValue(_ value: Int) {
    print("Rating : = ", value)
    }
}
查看更多
够拽才男人
7楼-- · 2019-03-17 22:31

I recommend HCSStarRatingView. It is native-looking and it also supports IB_DESIGNABLE and IBInspectable.

HCSStarRatingView

查看更多
登录 后发表回答