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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:52:30+00:00 2026-05-22T22:52:30+00:00

I am drawing several UIBezierPath s on a view based on finger movements. Every

  • 0

I am drawing several UIBezierPaths on a view based on finger movements.

Every time a cycle of touches — Began/Moved/Ended — completes, I store the points and create a UIBezierPath that is stored in an array called bezierArray. I have another array called bezierArrayColors that stores the colors of each path.

The problem is this. The class uses drawRect. As far as I can see, every time drawRect runs, it has to draw all the paths that were ever created and the app is now slow.

This is my drawRect now. I know it is pretty lame, but I am not seeing how this can be done.

- (void)drawRect:(CGRect)rect {
   for (int i=0; i<[self.bezierArray count]; i++) {
        UIBezierPath *aPath = (UIBezierPath*)[self.bezierArray objectAtIndex:i];
        UIColor *aColor = (UIColor*)[self.bezierArrayColor objectAtIndex:i];
    [aPath setLineWidth:LINE_WIDTH];

    [aColor setStroke];
    [aPath stroke];
    }
}

Is there a way to stroke a UIBezierPath with different colors or perhaps widths using subpaths? I mean, to change color, width and other properties of a subpath? That would allow me to use one UIBezierPath with several different subpaths. I wish one bezier could be drawn and left there without needing to be redrawn every time. What am I missing?

  • 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-22T22:52:31+00:00Added an answer on May 22, 2026 at 10:52 pm

    Make sure that you pay attention to the rect that’s passed into -drawRect:. If your code takes the easy way out and redraws the entire view every time -drawRect: is called, you may be doing far more drawing than necessary at least some of the time.

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

Sidebar

Related Questions

I am drawing several shapes (such as circles) that are keyed off of the
I'm writing a little plugin for imageJ and I am drawing several regions as
I have instantiated several System.Drawing.Icon Objects. Note that these are created at runtime and
I have found several articles on the Web regarding drawing a dashed line in
I created a custom object that has a Bitmap field. I'm drawing several of
I'm writing a drawing application that shows a tools view controller when the user
A program that animates circles is not drawing them fluidly once several hundred are
I have seen that in Cocoa I can create a custom view using drawing
I have several views inside one main view. Those views are all behind one
I'm playing around with 2D drawing within a custom view. So far I've got

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.