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

  • Home
  • SEARCH
  • 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 7503011
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T21:04:32+00:00 2026-05-29T21:04:32+00:00

I am trying to implement a custom UIView which is basically a pie menu

  • 0

I am trying to implement a custom UIView which is basically a pie menu (something like a cake divided into slices).

For that I am trying to draw a circle and a series of lines from the center, like the rays in a chart’s wheel.

I have successfully drawn the circle and and I would now like to draw the lines dividing the circle in slices.

This is what I have so far:

-(void)drawRect:(CGRect)rect{

     [[UIColor blackColor] setStroke];
     CGContextRef ctx = UIGraphicsGetCurrentContext();

    CGFloat minDim = (rect.size.width < rect.size.height) ? rect.size.width : rect.size.height;

    CGRect circleRect =  CGRectMake(0, rect.size.height/2-minDim/2, minDim, minDim); 

    CGContextAddEllipseInRect(ctx, circleRect);
    CGContextSetFillColor(ctx, CGColorGetComponents([[UIColor yellowColor] CGColor]));
    CGContextFillPath(ctx);

    CGPoint start = CGPointMake(0, rect.size.height/2);
    CGPoint end = CGPointMake(rect.size.width, rect.size.height/2);

    for (int i = 0; i < MaxSlices(6); i++){

        CGFloat degrees = 1.0*i*(180/MaxSlices(6));
        CGAffineTransform rot = CGAffineTransformMakeRotation(degreesToRadians(degrees));

        UIBezierPath *path = [self pathFrom:start to:end];
        [path applyTransform:rot];

    }
 }   

- (UIBezierPath *) pathFrom:(CGPoint) start to:(CGPoint) end{

    UIBezierPath*    aPath = [UIBezierPath bezierPath];
    aPath.lineWidth = 5;
    [aPath moveToPoint:start];
    [aPath addLineToPoint:end];
    [aPath closePath];
    [aPath stroke];
    return aPath;
}

The problem is that applyTransform on the path doesn’t seem to do anything. The first path gest drawn correctly the and the following ones are unaffected by the rotation. Basically what I see is just one path. Check the screen shot here http://img837.imageshack.us/img837/9757/iossimulatorscreenshotf.png

Thank you for your help!

  • 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-29T21:04:34+00:00Added an answer on May 29, 2026 at 9:04 pm

    You’re drawing the path (with stroke) before you transform it. A path is just a mathematical representation. It isn’t the line “on the screen.” You can’t move what you’ve already drawn by modifying the data about it.

    Just move the [aPath stroke] out of pathFrom:to: and put it after the applyTransform:.

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

Sidebar

Related Questions

I'm trying to implement a custom UIView that mimics the behavior of UIScrollView for
I'm trying to implement UINavigationBar with custom controls. So, I've added UIView on left
I'm trying to implement my custom authorize attribute like: public class MyCustomAuth : AuthorizeAttribute
Greetings, I'm trying to implement my custom TAB control. I'd like it to be
I'm trying to implement a custom log4net logger/logmanager so that I can add a
I'm trying to implement a custom combobox options popup, so that near each option
I'm trying to implement a custom menu in my joomla template. I added this
I am trying to create a custom UIView that is stored in a nib
I'm trying to implement a custom class for dataannotations that retrieves error messages from
I am trying to implement a custom menu for Internet Explorer 7.0. For this

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.