views:

269

answers:

1

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?

A: 

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.

Marcelo Cantos
I tried setNeedsDisplayInRect, but didn't work as expected, haha. xD
Johannes Jensen
Anyway, thanks for your help, I'll select your question as the right one if there doesn't appear one of more materiality.
Johannes Jensen
No probs. I'm not really sure what you are trying to achieve. If you can explain the objective in a bit more detail, then someone might be able to offer a more helpful answer.
Marcelo Cantos