开发者

Objective-C View drawRect: change the Rect

开发者 https://www.devze.com 2022-12-25 18:00 出处:网络
In my UIView\'s drawRect, there\'开发者_StackOverflow中文版s a parameter rect, which is a CGRect, where would I change this rect?

In my UIView's drawRect, there'开发者_StackOverflow中文版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.

0

精彩评论

暂无评论...
验证码 换一张
取 消