Làm thế nào để tô màu trong không gian màu trắng bằng cách sử dụng sự kiện cảm ứng?
muốn điền vào tất cả các không gian màu trắng với màu sắc khác nhau sử dụng cảm ứng sự kiện
Ngay bây giờ tôi có thể điền vào vòng tròn chọn màu sắc từ bảng chọn nhưng làm thế nào để lấp đầy phần intigrated với màu sắc khác nhau ......
-(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];
}
}
Không rõ bạn muốn gì. Bạn có thể đưa ra một giải thích từng bước về nơi người dùng sẽ chạm vào, và một hình ảnh cho thấy những phần nào sẽ được tô màu? –
trong hình trên nếu tôi nhấp vào bất kỳ khoảng trắng nào, nó sẽ được tô màu với một số màu –
Tôi đếm 8 khoảng trống riêng biệt trong ảnh đó, bao gồm cả phần bên ngoài của tất cả các vòng tròn. Bạn đếm bao nhiêu? –