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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
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.
This can’t be done. You will have to have some kind of marker to indicate a new line and then call
setNeedsDisplaymethod so that it invokes thedrawRect:method. You can check for the marker in thedrawRect: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,
This way you won’t have state but you simply add the line to the image.