Stars rating for iphone

I searched for a 5-star rating control for a while and did not find a solid solution. This question:

Does anyone know if there is a 5 star rating on the iPhone?

Provided several links to projects that are no longer available, and I could not track them.

Edit: I seem to be poorly versed in projects, but I think part of my question is still standing. Here is the updated link http://code.google.com/p/s7ratingview/downloads/detail?name=s7ratingview-basic-release.zip

So these questions are 2 parts. Is there a complete turnkey solution, and could you send me to it?

Is it better / pretty easy (yes, I understand that these two sides are in conflict) grow my own decisions? Could you give me some tips / resources for this. I understand the basic idea of ​​subclassing UIView and tracking touch events in order to expand the image on top of another image to look like stars, but a little more would be helpful. I have been developing on iphone in less than a week and still need a little hands.

+4
source share
4 answers

Try a custom UIView from Ray Wenderlich with a 5-star rating.


[EDIT]

You can also try UISlider and provide min / max images of tracks.

+8
source

You can try DYRateView . I wanted to use the Ray tutorial as much as possible, but it lacked a few functions, so I created it myself.

You can check my blog for more information on how to use DYRateView in your project: http://iappexperience.com/post/23227218867/dyrateview-a-simple-yet-powerful-rating-control-for .

picture

picture

+9
source

Another way you can try DLStarRating is to adjust the area under the stars by detecting touches.

enter image description here

+1
source

It's easy to give a star. Follow this code and copy and paste into your project and just run.

- (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view from its nib. startview = [[UIView alloc] initWithFrame:CGRectMake(45, 70, 230, 50)]; startview.backgroundColor = [UIColor redColor]; NSInteger getrating = 0; int x = 5; for (int k = 1; k <= 5; k++) { UIImageView * mystarimage = [[UIImageView alloc] initWithFrame:CGRectMake(x, 5, 40, 40)]; if (getrating >= k) { mystarimage.image = [UIImage imageNamed:@"star.png"]; } else { mystarimage.image = [UIImage imageNamed:@"gray-star.png"]; } mystarimage.tag = k; mystarimage.userInteractionEnabled = YES; [startview addSubview:mystarimage]; UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(updateStar:)]; rateMember = mystarimage.tag; NSLog(@"rateing %ld",(long)rateMember); letterTapRecognizer.numberOfTapsRequired = 1; [mystarimage addGestureRecognizer:letterTapRecognizer]; x = x + 45; } [self.view addSubview:startview]; } -(void)updateStar :(UITapGestureRecognizer*)sender { UIView *view = sender.view; NSLog(@"hello ji %ld", (long)view.tag); NSInteger getrating; switch (view.tag) { case 1: NSLog(@"press 1"); rateMember = 1; break; case 2: NSLog(@"press 2"); rateMember = 2; break; case 3: NSLog(@"press 3"); rateMember = 3; break; case 4: NSLog(@"press 4"); rateMember = 4; break; case 5: NSLog(@"press 4"); rateMember = 5; break; default: NSLog(@"press 5"); rateMember = 5; break; } getrating = rateMember; NSLog(@"Get rating -------> %ld",(long)getrating); int x = 5; for (int k = 1; k <= 5 ; k++) { UIImageView * mystarimage = [[UIImageView alloc] initWithFrame:CGRectMake(x, 5, 40, 40)]; if (getrating >= k) { mystarimage.image = [UIImage imageNamed:@"star.png"]; } else { mystarimage.image = [UIImage imageNamed:@"gray-star.png"]; } mystarimage.tag = k; mystarimage.userInteractionEnabled = YES; [startview addSubview:mystarimage]; UITapGestureRecognizer *letterTapRecognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(updateStar:)]; letterTapRecognizer.numberOfTapsRequired = 1; [mystarimage addGestureRecognizer:letterTapRecognizer]; x = x + 45; } } 
0
source

Source: https://habr.com/ru/post/1334971/


All Articles