码迷,mamicode.com
首页 > 其他好文 > 详细

评分系统(小星星,仿我要去旅行)

时间:2014-10-20 21:20:32      阅读:253      评论:0      收藏:0      [点我收藏+]

标签:style   blog   http   color   io   ar   sp   div   2014   

 

 

效果图:

bubuko.com,布布扣

代码:

 

 

- (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;
}

 

 

 

 

评分系统(小星星,仿我要去旅行)

标签:style   blog   http   color   io   ar   sp   div   2014   

原文地址:http://www.cnblogs.com/yang-guang-girl/p/4038566.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!