How do I MOVE a circle drawn in a subclass of UIView by overwriting the method "drawRect"??
Posted
by Christoph v
on Stack Overflow
See other posts from Stack Overflow
or by Christoph v
Published on 2010-05-07T14:24:56Z
Indexed on
2010/05/07
14:28 UTC
Read the original article
Hit count: 392
objective-c
hi, I'm trying to figure out what i'm doing wrong but i just don't get it. Here is what i want to do:
I want to draw a circle somewhere on the screen of the iphone and then i want the circle always to be displayed at the position where the user currently taps on the screen. I started by creating a subclass of UIView and adding the following lines into the "drawRect" method:
- (void)drawRect:(CGRect)rect {
//Create the main view!
CGContextRef mainscreen = UIGraphicsGetCurrentContext();
//Draw the dot
//will be a circle cause rectangle is a square
CGRect dotRect = CGRectMake(50, 80, 100, 100);
[[UIColor blueColor] set];
CGContextStrokeEllipseInRect(mainscreen, dotRect);
CGContextFillEllipseInRect(mainscreen, dotRect);
}
The appears just fine but now i have no idea how to make it move around on the screen i've tried serveral things and nothing worked pls help!
© Stack Overflow or respective owner