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 4616104
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:56:05+00:00 2026-05-22T01:56:05+00:00

For those times when a UISlider just isn’t fun enough I was thinking I’d

  • 0

For those times when a UISlider just isn’t fun enough I was thinking I’d work up a custom UIControl to do something similar to a Google O Meter from the google chart API on iOS.

Here’s an example of what I’m talking about visually. My goal would be to enable touch manipulation of the needle and easy customization of the range labels and coloring gradients. The Google Charts API is a great inspiration:

Before I re-invent the wheel is anyone aware of an existing effort I could leverage good sample code with something like this or project I could contribute too?

Thanks for any pointers.

  • 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-22T01:56:05+00:00Added an answer on May 22, 2026 at 1:56 am

    I have implemented a GaugeView as a child of UIView and added the code to draw the gauge in the drawRect method. Nothing fancy but may be helpful to start

     - (void)drawRect:(CGRect)rect {
    
         [super drawRect:rect];
         CGRect parentViewBounds = self.bounds;
         CGFloat x = CGRectGetWidth(parentViewBounds)/2;
         CGFloat y = CGRectGetHeight(parentViewBounds);
         CGFloat radius = y;
         CGFloat percent_angle = _progress * M_PI;
    
         CGContextRef ctx = UIGraphicsGetCurrentContext();
         CGContextBeginPath(ctx);
    
         // Add path
         CGFloat m2_x = radius * (1.0 - 0.9*cos(percent_angle));
         CGFloat m2_y = radius * (1.0 - 0.9*sin(percent_angle));      
    
         CGContextBeginPath(ctx);
         CGContextAddArc(ctx, x, y, radius, M_PI, 0, 0);
         CGContextAddLineToPoint(ctx, x + 0.1*radius, y);
         CGContextAddArc(ctx, x, y, 0.1*radius, 0, M_PI, 1);
         CGContextClosePath(ctx);
         CGContextSetFillColorWithColor(ctx,[UIColor whiteColor].CGColor);
         CGContextFillPath(ctx);
    
         CGContextBeginPath(ctx);
         CGContextMoveToPoint(ctx, m2_x, m2_y);
         CGContextAddArc(ctx, x, y, 0.9*radius, M_PI + percent_angle, M_PI, 1);
         CGContextAddLineToPoint(ctx, 0.8*radius, y);
         CGContextSetStrokeColorWithColor(ctx,self.fillColor.CGColor);
         CGContextAddArc(ctx, x, y, 0.2*radius, M_PI, M_PI + percent_angle, 0);
         CGContextClosePath(ctx);
         CGContextStrokePath(ctx);
    
         CGContextBeginPath(ctx);
         CGContextMoveToPoint(ctx, m2_x, m2_y);
         CGContextSetFillColorWithColor(ctx,self.fillColor.CGColor);
         CGContextAddArc(ctx, x, y, 0.9*radius, M_PI + percent_angle, M_PI, 1);
         CGContextAddLineToPoint(ctx, 0.8*radius, y);
         CGContextAddArc(ctx, x, y, 0.2*radius, M_PI, M_PI + percent_angle, 0);
         CGContextClosePath(ctx);
         CGContextFillPath(ctx);
    
        /* CGContextBeginPath(ctx);
         CGContextAddArc(ctx, x, y, radius, M_PI, 0, 0);
         CGContextAddLineToPoint(ctx, x + 0.1*radius, y);
         CGContextAddArc(ctx, x, y, 0.1*radius, 0, M_PI, 1);
         CGContextClosePath(ctx);
         CGContextSetStrokeColorWithColor(ctx,[self.strokeColor CGColor]);
         CGContextStrokePath(ctx);*/
    
         for(int i = 0; i < 100; i++)
         {
             CGFloat angle =M_PI * 0.01 * i;
             CGFloat l1_x = radius * (1.0 - 0.98*cos(angle));
             CGFloat l1_y = radius * (1.0 - 0.98*sin(angle));
             if(i%10 == 0)
             {
                 l1_x = radius * (1.0 - 0.9*cos(angle));
                 l1_y = radius * (1.0 - 0.9*sin(angle));
             }
             else if(i%5 == 0)
             {
                 l1_x = radius * (1.0 - 0.95*cos(angle));
                 l1_y = radius * (1.0 - 0.95*sin(angle));             
             }
    
             CGFloat l2_x = radius * (1.0 - cos(angle));
             CGFloat l2_y = radius * (1.0 - sin(angle)); 
             CGContextMoveToPoint(ctx, l1_x, l1_y);
             CGContextSetLineWidth(ctx, 1.0);
             CGContextAddLineToPoint(ctx, l2_x, l2_y);
             CGContextSetStrokeColorWithColor(ctx,[self.strokeColor CGColor]);
             CGContextStrokePath(ctx);
         }
    
         CGFloat n1_x = radius * (1.0 - 0.1*cos(percent_angle));
         CGFloat n1_y = radius * (1.0 - 0.1*sin(percent_angle));
         CGFloat n2_x = radius * (1.0 - cos(percent_angle));
         CGFloat n2_y = radius * (1.0 - sin(percent_angle)); 
         CGContextMoveToPoint(ctx, n1_x, n1_y);
         CGContextSetLineWidth(ctx, 4.0);
         CGContextAddLineToPoint(ctx, n2_x, n2_y);
         CGContextSetStrokeColorWithColor(ctx,[self.needleColor CGColor]);
         CGContextStrokePath(ctx);
    
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

As in, distance_of_time(Time.now, Time.tomorrow).days = 1 or something along those lines? If not, what
At work we have a base class, let's call it IntrusiveBase, that acts something
This is one of those times when only the hive mind can help -
I'd like to know what's the default approach for those times when you need
I've got times saved in a sql database in utc format. I'm displaying those
T-SQL DateTime Question. I have a set of time ranges. During those time ranges
So the official XML-RPC standard doesn't support 64-bit values. But in these modern times,
I have recently run across these terms few times but I am quite confused
Many times I've seen links like these in HTML pages: <a href='#' onclick='someFunc(3.1415926); return
Many times I saw logging of errors like these: System.out.println(Method aMethod with parameters a:+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.