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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T17:27:52+00:00 2026-06-10T17:27:52+00:00

i added a custom view and want to draw an inner smaller circle, outer

  • 0

i added a custom view and want to draw an inner smaller circle, outer bigger circle and and perpendicular line. the drawRect: method in my class looks like this.

- (void) drawRect:(CGRect)rect{
    CGContextRef myContext = UIGraphicsGetCurrentContext();
    float height = rect.size.height;
    float width = rect.size.width;
    CGContextTranslateCTM(myContext, 0.0, height);
    CGContextScaleCTM(myContext, 1.0, -1.0);
    CGPoint middle = CGPointMake(width/2, height/2);
    UIBezierPath *innerCirclePath = [UIBezierPath bezierPathWithArcCenter:middle radius:25 startAngle:0 endAngle:DEGREES_TO_RADIANS(360) clockwise:YES];
    [innerCirclePath setLineWidth:2];
    [[UIColor redColor] setStroke];
    [innerCirclePath stroke];
    UIBezierPath *outerCirclePath = [UIBezierPath bezierPathWithArcCenter:middle radius:120 startAngle:0 endAngle:DEGREES_TO_RADIANS(360) clockwise:NO];
    [outerCirclePath setLineWidth:2];
    [[UIColor greenColor] setStroke];
    [outerCirclePath stroke];
    UIBezierPath *xAxis = [UIBezierPath bezierPath];
    [xAxis moveToPoint:CGPointMake(width, height/2 - 150)];
    [xAxis addLineToPoint:CGPointMake(width, height/2 + 150)];
    [xAxis closePath];
    [[UIColor grayColor] setStroke];
    [xAxis setLineWidth:2];
    [xAxis stroke];
}

Now I do get the circles, both outer and inner but there is no perpendicular line that I wanted. Why is it not getting drawn?

  • 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-06-10T17:27:54+00:00Added an answer on June 10, 2026 at 5:27 pm

    You’re using these two lines to set up the path for your “perpendicular line”:

    [xAxis moveToPoint:CGPointMake(width, height/2 - 150)];
    [xAxis addLineToPoint:CGPointMake(width, height/2 + 150)];
    

    The problem is that the X coordinate of both points is the right edge of your view. Perhaps you want it to be at the center of your view:

    CGFloat xMid = CGRectGetMidX(rect);
    [xAxis moveToPoint:CGPointMake(xMid, height/2 - 150)];
    [xAxis addLineToPoint:CGPointMake(xMid, height/2 + 150)];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've added orientation attribute to my custom view, and i want to compare it's
In my custom View which I have added to my viewControllers's view, I need
In my iOS application, I'm using custom NavigationItem (added to root view from Nib
I have a table view controller with custom cells. In those cells i added
I added a custom validation method to validate a password. However, it does not
I have few custom controls (image views) added programmatically to table cell. I want
In my rails(2.x) application. I want to use custom font in my view. So
I have a Custom Scroll View, subclassing UIScrollView . I have added a scroll
xml and logcat now added, now custom view code, unfortunately i am away from
I have an UINavigationBar added to my UIViewController view. I want to change the

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.