评分 星星视图

来源:互联网 发布:电力工程计价软件 编辑:程序博客网 时间:2024/05/16 14:44

        self.startArray = [[NSMutableArray alloc] init]; 



        self.startView = [[UIView alloc] initWithFrame:

                             CGRectMake(self.shopImgView.origin.x,

                                        self.shopImgView.origin.y + self.shopImgView.height + 10,

                                        self.shopImgView.width,

                                        bgView.height - self.shopImgView.origin.y - self.shopImgView.height)];

        

        for (int i = 0; i < 5; i++)

        {

            UIImage *img = [UIImage imageNamed: @"start_none"];

            UIImageView *imgView = [[UIImageView alloc] initWithFrame: CGRectMake(i * 17 + 5, 0, 15, 13)];

            [imgView setImage: img];

            

            [self.startArray addObject: imgView];

            [self.startView addSubview: imgView];

        }




    float f = [model.praise floatValue]/20;

    int backTwoInt = (int)(f * 100) % 100;

    int startNum = floorf(f);

    

    //NSLog(@"startNum:%d",startNum);

    if (startNum > 5) {

        startNum = 5;

        

    }

    for (int i = 0; i < startNum; i ++)

    {

        UIImageView *imgView = [self.startArray objectAtIndex: i];

        [imgView setImage: [UIImage imageNamed: @"start_all"]];


    }

    

    if (backTwoInt >= 50)

    {

        if (startNum == 5)

        {

            return;

        }

        UIImageView *imgView = [self.startArray objectAtIndex: startNum];

        [imgView setImage: [UIImage imageNamed: @"start_half"]];

    }

    else

    {

        if (startNum == 5)

        {

            return;

        }

        UIImageView *imgView = [self.startArray objectAtIndex: startNum];

        [imgView setImage: [UIImage imageNamed: @"start_none"]];


    }

    

    

0 0
原创粉丝点击