터치 좌표를 중심으로 원을 그리도록 앱을 만들고 싶습니다.iOS 5 - 터치시 원을 그립니다.
여기에 제가 지금 가지고있는 코드가 있습니다. 확실히 엉망입니다. 나는 물건을 그리거나 문맥을 다루는 연습을하지 않았습니다. 내가 여기서 무엇을 놓치고 있니? 미리 감사드립니다.
보기 컨트롤러의 UIViewController
@implementation ViewController
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
}
- (void)viewDidUnload
{
[super viewDidUnload];
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *theTouch = [touches anyObject];
[self doSomething];
//[self.view setNeedsDisplay];
}
- (void) drawCircleAtPoint:(CGPoint)point withRadius:(CGFloat)radius inContext:(CGContextRef)context{
UIGraphicsPushContext(context);
CGContextBeginPath(context);
CGContextAddArc(context, point.x, point.y, radius, 0, 2*M_PI, YES);
CGContextFillPath(context);
UIGraphicsPopContext();
}
- (void)drawRect:(CGRect)rect
{
CGPoint point;
CGContextRef context = UIGraphicsGetCurrentContext();
point.x = self.view.bounds.origin.x + self.view.bounds.size.width/2;
point.y = self.view.bounds.origin.y + self.view.bounds.size.height/2;
CGContextSetLineWidth(context, 5.0);
[[UIColor whiteColor] setFill];
[self drawCircleAtPoint:point withRadius:50 inContext:context];
}
@end
여기
나는 그것이 적어도 화면의 중앙에 원을 그리는 원의 서브 클래스입니다,하지만 난이 작업을 수행 할 수 없습니다. 의 UIViewController보기를 관리하고, 위임 및 기타 관련 항목 자체를 처리 -
왜 하얀 채우기를하고 있니? 배경색은 무엇입니까? – heckman