有没有在可可中渲染图像的最佳方法?我正在使用 setNeedsDisplay
目前,每当我手动移动 UIImage(通过处理 TouchMoved 事件)时,我在该事件中调用的最后一件事是 [self setNeedsDisplay],它会有效地重绘整个视图。
我的图像也是动画的,所以每次动画帧发生变化时,我都必须调用 setNeedsDisplay。
我发现这很可怕,因为我不希望 iphone/cocoa 能够非常快地执行如此频繁的屏幕重绘。
有没有一种最佳、更有效的方法可以做到这一点? 也许以某种方式告诉可可只更新屏幕的特定区域(图像的矩形区域)?
Currently, any time I manually move a UIImage (via handling the touchesMoved event) the last thing I call in that event is [self setNeedsDisplay], which effectively redraws the entire view.
My images are also being animated, so every time a frame of animation changes, i have to call setNeedsDisplay.
I find this to be horrific since I don't expect iphone/cocoa to be able to perform such frequent screen redraws very quickly.
Is there an optimal, more efficient way that I could be doing this?
Perhaps somehow telling cocoa to update only a particular region of the screen (the rect region of the image)?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
setNeedsDisplayInRect: 正是您所需要的。
请参阅 developer.apple.com 上的文档
setNeedsDisplayInRect: does exactly what you need.
See documentation at developer.apple.com