重新繪製矩形,我這樣做...
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event{
myState = 1;
[self setNeedsDisplay];
}
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
myState = 0;
[self setNeedsDisplay];
}
- (void)drawRect:(CGRect)rect
{
// Drawing code
NSLog(@"drawRect state: %d", self.state);
NSLog(@"rect %@", NSStringFromCGRect(self.frame));
c = UIGraphicsGetCurrentContext();
if (myState==0){
///////// plot border /////////////
CGContextBeginPath(c);
CGContextSetLineWidth(c, 2.0);
CGContextMoveToPoint(c, 1, 1);
CGContextAddLineToPoint(c, 1, 20);
CGContextAddLineToPoint(c, 299, 20);
CGContextAddLineToPoint(c, 299, 1);
CGContextSetRGBFillColor(c, 0.0, 0.0, 1.0, 1.0);
CGContextFillPath(c);
CGContextClosePath(c);
CGContextStrokePath(c);
}else{
CGContextBeginPath(c);
CGContextSetLineWidth(c, 2.0);
CGContextMoveToPoint(c, 1, 20);
CGContextAddLineToPoint(c, 1, 40);
CGContextAddLineToPoint(c, 299, 40);
CGContextAddLineToPoint(c, 299, 20);
CGContextSetRGBFillColor(c, 1.0, 0.0, 1.0, 1.0);
CGContextFillPath(c);
CGContextClosePath(c);
CGContextStrokePath(c);
}
}
來源
2012-03-04 04:41:26
jdl
好吧,我能夠通過(跟蹤觸摸和重繪控制)得到狀態......但我不知道如何正確地做到這一點......開始繼續結束 – jdl 2012-03-04 03:24:30
這最有可能是容易,只需提供一些圖片的不同狀態... – 2012-03-04 03:30:26
我要繪製各種色調和,並根據先前的選擇的東西...數學計算 – jdl 2012-03-04 03:34:53