Tutorial :Objective-C View drawRect: change the Rect


In my UIView's drawRect, there's a parameter rect, which is a CGRect, where would I change this rect?

I'd like to use it as a camera for a game that I am making,

such as

rect.origin.x = myCamera.x;  rect.origin.y = myCamera.y;  

and then my drawing functions should draw it where the camera is placed...

How would I change the rect?


You can't control this value. The underlying framework decides what area of the view needs to be drawn and sets the value accordingly.

You can call setNeedsDisplayinRect: and the framework might pass the rect you supply as the rect parameter to drawRect, but there are no guarantees, AFAIK.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »