我目前正在尝试刷新或清除我的 UIView
绘图,但很多方法都不起作用。我尝试过:
self.Draw.clearsContextBeforeDrawing
[self.Draw setNeedsDisplay];
self.Draw.removeFromSuperview;
我的代码:
-(void)drawPoint:(UITouch *)touch
{
PointLocation *currentLoc = [[PointLocation alloc] init];
currentLoc.location = [touch locationInView:self];
self.previousPoint = self.point;
self.point = currentLoc;
[self drawToBuffer];
[self setNeedsDisplay];
}
有什么方法可以清除我的 uidraw 吗?或者至少重新加载它?
最佳答案
这里有一些基本问题。
Draw 是如何声明的?遵循 cocoa 命名约定。只有类名应该大写。类的实例应以小写字母开头。
我认为你想要的是:
@interface Draw: UIView
@end
@implementation Draw
- (void) drawRect: (CGRect) r {
// here you will draw whatever you want in your view.
}
@end
Draw* draw;
在你的drawPoint方法中:
[draw setNeedsDisplay];
有关更多详细信息,请参阅 View 绘制周期: http://developer.apple.com/library/ios/documentation/UIKit/Reference/UIView_Class/UIView/UIView.html#//apple_ref/doc/uid/TP40006816-CH3-SW136
为了获得奖励积分,请将您的 View 命名为比“绘制”更具描述性的名称。它是某事物的 View ,是包含某些内容的窗口。它不是动词。
关于objective-c - 如何清除绘制 uiview?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11838418/