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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:54:58+00:00 2026-05-23T13:54:58+00:00

I need to draw on my uiview without using the drawrect method but i

  • 0

I need to draw on my uiview without using the drawrect method but i don’t know how to get the graphics context dynamically at any point of time?

For example: I need to add a line when user selected the add line from from pop over in my toolbar.

  • 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-23T13:54:59+00:00Added an answer on May 23, 2026 at 1:54 pm

    This can’t be done. You will have to have some kind of marker to indicate a new line and then call setNeedsDisplay method so that it invokes the drawRect: method. You can check for the marker in the drawRect: method and draw the line accordingly.

    You will have to save state. Probably an array of lines added so that you can use it to draw the view when drawRect: method is invoked.

    An alternative

    You can use an image view for this purpose. You can do this,

    UIGraphicsBeginImageContext(imageView.frame.size);
    [imageView.image drawInRect:CGRectMake(0, 0, imageView.frame.size.width, imageView.frame.size.height)];
    /* Draw line here */
    imageView.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    

    This way you won’t have state but you simply add the line to the image.

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

Sidebar

Related Questions

I need to draw a .png image on an UIView. I have no clue
For example, I want to draw something directly to an UIView. I need an
I need to draw on a TPanel, ideally directly so I don't have another
I need to draw text onto a window HDC along a circular path using
I need to draw a line one inch long on any device given a
I need to draw a horizontal line in a UIView. What is the easiest
i need to draw two lines. can i use the same UIView subclass to
I need to draw a Gantt-Chart within my iPad App. Are there any frameworks
I created a subclass of UIView that overrides drawRect: and uses AddArcToPoint() to draw
I need to draw 3d projections and i am using opengl wrapper for JAVA.

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.