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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:25:23+00:00 2026-05-28T08:25:23+00:00

i need to draw two lines. can i use the same UIView subclass to

  • 0

i need to draw two lines. can i use the same UIView subclass to make both draws? after i create the UIView

draw2D *myView = [[draw2D alloc] initWithFrame:myRect];

if i change the method to use variables, can i change those values and recall the drawRect method to draw a different line?

- (void)drawRect:(CGRect)rect
{
    CGContextRef context01 = UIGraphicsGetCurrentContext();

    CGContextSetLineWidth(context01, 1.0);
    CGContextSetStrokeColorWithColor(context01, [[UIColor blackColor]CGColor]);
    CGContextMoveToPoint(context01, 0, 0);
    CGContextAddLineToPoint(context01, 800, 0);
    CGContextStrokePath(context01);

    CGContextRef context02 = UIGraphicsGetCurrentContext();

    CGContextSetLineWidth(context02, 1.0);
    CGContextSetStrokeColorWithColor(context02, [[UIColor blackColor]CGColor]);
    CGContextMoveToPoint(context02, 453, 0);
    CGContextAddLineToPoint(context02, 453, 800);
    CGContextStrokePath(context02);
}
  • 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-28T08:25:24+00:00Added an answer on May 28, 2026 at 8:25 am

    Just call setNeedsDisplay on a view to force its drawRect method to be called again.

    It doesn’t redraw the view immediately, but it flags it as needing to be drawn again in the next view update cycle (updates happen roughly every 60th second). That means you can call setNeedsDisplay multiple times with no performance penalty.

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

Sidebar

Related Questions

I need to draw two lines of text in a 3D perspective. They're not
I need to draw a graph of write accesses of two concurrently running threads.
I need to draw a .png image on an UIView. I have no clue
I have data with a best fit line draw. I need to draw two
so i need to draw 2 different lines. through another posting , i figured
I want to use a color picker to pick two colors and then draw
I've got a custom view in which I need to draw two bitmaps, one
How can I draw two or more jQuery progressbar with diffrent values inside the
I need to show the same object in OpenGL in two different viewports, for
I have two Point structures and I need to draw an I-Beam based on

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.