Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Call drawRect programmatically in objective c

Tags:

How to Call drawRect programmatically in objective c ?

I want to call drawrect method of a view in my UItabbarcontroller. How i can do this ? Thanks in advance..

Edit

I have to call when the view is not visible currently. It will be the first time i have to call that view

like image 796
S.P. Avatar asked May 04 '10 10:05

S.P.


2 Answers

[myView.layer display]; 

Forces the view to draw itself straight away.

[myView setNeedsDisplay: YES]; 

Forces the view to redraw on the next event loop cycle.

However, if you need to call it even when it is not visible, I think there is something wrong with the design of your view class. You should only be doing drawing inside drawRect: not anything else. And if you are only doing drawing why do it when the view is not visible?

like image 126
JeremyP Avatar answered Dec 16 '22 17:12

JeremyP


setNeedsDisplay

like image 30
ohho Avatar answered Dec 16 '22 18:12

ohho