[Code note] the scoring system (Xiaoxing) and the scoring system Xiaoxing

Source: Internet
Author: User

[Code note] the scoring system (Xiaoxing) and the scoring system Xiaoxing

I ,.

 

2. Engineering Drawing.

3. Code.

RootViewController. m

-(Void) viewDidLoad {[super viewDidLoad]; // Do any additional setup after loading the view. UIImageView * imageView = [[UIImageView alloc] initWithFrame: CGRectMake (10, 80,300, 50)]; // picture for scoring [imageView setImage: [self setStarImage: @ "4"]; imageView. backgroundColor = [UIColor clearColor]; [self. view addSubview: imageView];} // returns the Image Based on the score-(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 ;}

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.