[SDK]iPhoneアプリ開発初心者質問箱34[touch][iPad]
■ このスレッドは過去ログ倉庫に格納されています
0541名称未設定
2013/09/22(日) 04:15:25.91ID:rncE9ZP30たぶんあれでしょ、描画だけじゃなくhitTestもしたいんでしょ?
//メンバー
CGMutablePathRef mPaths[20];
int hitIndex;
BOOL hit;
- (void)createPaths {
CGPoint arcCenter = CGPointMake(self.bounds.size.width/2, self.bounds.size.height/2);
CGFloat arcRadius = 100.0;
for (int i=0; i<20; i++) {
CGFloat startAngle = -0.5*M_PI + i * 2*M_PI/20;
CGFloat endAngle = startAngle + 2*M_PI/20;
mPaths[i] = CGPathCreateMutable();
CGPathMoveToPoint(mPaths[i], NULL, arcCenter.x, arcCenter.y);
CGPathAddArc(mPaths[i], NULL, arcCenter.x, arcCenter.y, arcRadius, startAngle, endAngle, 0);
CGPathCloseSubpath(mPaths[i]);
}
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
CGPoint p = [[touches anyObject] locationInView:self];
hit = NO;
for (int i=0; i<20; i++) {
if (CGPathContainsPoint(mPaths[i], NULL, p, NO)) {
hitIndex = i; hit = YES; break;
}
}
[self setNeedsDisplay];
}
■ このスレッドは過去ログ倉庫に格納されています