Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 260131
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T22:19:20+00:00 2026-05-11T22:19:20+00:00

I have a (float) rating value as a percentage from 0..100 (where 50 =

  • 0

I have a (float) rating value as a percentage from 0..100 (where 50 = Just OK, 0 = terrible and 100=best).

What’s a simple way to display this as a 5 star rating on the iphone, with the following requirements:

  • simple (ideally just using drawing operations based on a png of a single star or five of them, and without needing to resort to photoshop.)
  • reasonably fast (this is part of a cell in a table view)
  • includes half stars (or more fine grained)
  • displays something reasonable for a rating of 0 (or close to 0)

(This is display only so I don’t need it to respond to touch events, though that would be nice – currently I’m just using a slider to capture the rating in the first place)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T22:19:20+00:00Added an answer on May 11, 2026 at 10:19 pm

    I’ve come up with a simple way to do this without using any PNGs at all. I’ve subclassed a UIView and then in the drawRect I’ve done this:

    - (void)drawRect:(CGRect)rect {
        // Drawing code
        CGContextRef context = UIGraphicsGetCurrentContext();
        [textColor set];
        NSString* stars=@"★★★★★";
        rect=self.bounds;
        UIFont *font = [UIFont boldSystemFontOfSize: 16];
        CGSize starSize = [stars sizeWithFont: font];
        rect.size=starSize;
        [@"☆☆☆☆☆" drawInRect:rect withFont: font];
        CGRect clip=rect;
        clip.size.width=clip.size.width*rating/100;
        CGContextClipToRect(context,clip);
        [stars drawInRect:rect withFont:font];
    }
    

    (those strings are 5 empty and 5 full stars, in case they are only displaying on my mac. I just entered them within IB using the ‘special characters’ menu)

    I’ve added a textColor (UIColor*) and rating (int) property, so that is where those are coming from.

    To add the view within IB, I just change the class type to the name of my UIView subclass. Then I can add the view to any container within IB.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

If you have a float in MSSQLServer, to what do you map this in
I have a function that returns a float from 0 to 255. I would
So I have a function that looks something like this: float function(){ float x
I have double (or float) variables that might be empty, as in holding no
Both are mathematical values, however the float does have more precision. Is that the
I have a Div with five float divs inside: var div=document.createElement(div); div.className=cssDivNino; var divFolio=document.createElement(div);
Mine would have to be the float and margin bugs... If you float an
I want to have two items on the same line using float: left for
I have a div with two nested divs inside, the (float:left) one is the
I have an annoying CSS layout problem. I'm trying to float images on a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.