首页 > 代码库 > 评分系统(小星星,仿我要去旅行)
评分系统(小星星,仿我要去旅行)
效果图:
代码:
- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view. UIImageView *imageView=[[UIImageView alloc] initWithFrame:CGRectMake(10, 80, 300, 50)]; //获得评分的图片 [imageView setImage:[self setStarImage:@"4"]]; imageView.backgroundColor=[UIColor clearColor]; [self.view addSubview:imageView]; }//根据分数,反回图片-(UIImage *)setStarImage:(NSString *)str{ float a=atof([str UTF8String]); UIImage * image; if(a==0.000000){ image=[UIImage imageNamed:@"star0.png"]; }else if(a>0.000000&&a<1.000000){ image=[UIImage imageNamed:@"star1.png"]; }else if(a==1.000000){ image=[UIImage imageNamed:@"star2.png"]; }else if(a>1.000000&&a<2.000000){ image=[UIImage imageNamed:@"star3.png"]; }else if(a==2.000000){ image=[UIImage imageNamed:@"star4.png"]; }else if(a>2.000000&&a<3.000000){ image=[UIImage imageNamed:@"star5.png"]; }else if(a==3.0000000){ image=[UIImage imageNamed:@"star6.png"]; }else if(a>3.000000&&a<4.000000){ image=[UIImage imageNamed:@"star7.png"]; }else if(a==4.000000){ image=[UIImage imageNamed:@"star8.png"]; }else if(a>4.000000&&a<5.000000){ image=[UIImage imageNamed:@"star9.png"]; }else if(a==5.000000){ image=[UIImage imageNamed:@"star10.png"]; } return image;}
评分系统(小星星,仿我要去旅行)
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。