我的应用程序允许用户在屏幕上拖动圆圈。 我想知道是否要采取任何标准步骤来实现这一目标,尤其是在将正确的视图区域标记为脏区域方面。 我目前正在执行以下操作:
//Get initial touch point and draw a circle there. Use touch point and size of circle to pass the mark the appropriate CGRect as dirty so that it gets redrawn
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
//Get new touchpoint and draw a circle there. Use the union of the previous CGRect and the new one (based on the touch point and circle size) to tell drawRect: what area of the screen to redraw.
- (void) touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
这看起来是否正确,还是我应该做一些其他基本工作?
假设您的观点就是绘制圆圈,那么您在做什么就可以了。 只需使用[self setNeedsDisplayInRect: circleRect]
将圆的先前和新位置标记为脏。