come riempire il colore negli spazi bianchi usando l'evento tattile?
desidera riempire tutti gli spazi bianchi con colore differente che utilizzano eventi touch
In questo momento ho in grado di riempire i cerchi scegliere i colori da picker, ma come per riempire la parte intigrated con colore differente ......
-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
UIColor *cl=[UIColor clearColor];
UITouch *tuch=[touches anyObject];
if ([clr isEqualToString:@"Red"]) {
cl=[UIColor redColor];
}
else if ([clr isEqualToString:@"Blue"]) {
cl=[UIColor blueColor] ;
}
else if ([clr isEqualToString:@"Green"]) {
cl=[UIColor greenColor];
}
CGPoint p = [tuch locationInView:self];
float xsq1=p.x -50;
xsq1=xsq1*xsq1;
float ysq1=p.y-110;
ysq1=ysq1*ysq1;
float h1 = ABS(sqrt(xsq1 + ysq1));
float xsq2=p.x -100;
xsq2=xsq2*xsq2;
float ysq2=p.y-110;
ysq2=ysq2*ysq2;
float h2 = ABS(sqrt(xsq2 + ysq2));
float xsq3=p.x -50;
xsq3=xsq3*xsq3;
float ysq3=p.y-190;
ysq3=ysq3*ysq3;
float h3 = ABS(sqrt(xsq3 + ysq3));
if (h1<=40) {
NSLog(@"touches inside of first circle");
CGContextSetFillColorWithColor(context, cl.CGColor);
CGRect cir1 = CGRectMake(10,266,80,80);
CGContextFillEllipseInRect(context, cir1);
[self setNeedsDisplayInRect:cir1];
}
else if (h2<=40) {
NSLog(@"touches inside of second circle");
CGContextSetFillColorWithColor(context, cl.CGColor);
CGRect cir2 = CGRectMake(60,266,80,80);
CGContextFillEllipseInRect(context, cir2);
[self setNeedsDisplayInRect:cir2];
}
}
Non è chiaro cosa vuoi. Puoi dare una spiegazione dettagliata di dove l'utente dovrebbe toccare e un'immagine che mostra quali parti devono essere colorate? –
nell'immagine sopra se clicco su qualsiasi spazio bianco dovrebbe essere colorato con un po 'di colore –
Conto 8 spazi separati in quella foto, inclusa la parte esterna a tutti i cerchi. Quanti ne contate? –