我的应用允许用户在屏幕上拖动圈子。我想知道是否有任何标准步骤来实现这一点,特别是在将视图的正确区域标记为脏的方面。我目前正在做以下事情:
//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 {
这看起来是对的,还是我应该做的其他基本部分?
答案 0 :(得分:1)
假设你的观点是绘制圆圈的,那么你所做的应该没问题。只需使用[self setNeedsDisplayInRect: circleRect]
将圆圈的上一个和新位置标记为脏。