Ios 旋转拨号器式动画
我正在使用MHRotaryKnob制作类似转盘的动画。我正在用它做旧的电话拨号盘Ios 旋转拨号器式动画,ios,iphone,uiviewanimation,Ios,Iphone,Uiviewanimation,我正在使用MHRotaryKnob制作类似转盘的动画。我正在用它做旧的电话拨号盘目前,当我拨键盘时,它只是显示动画,它只是带着动画返回。即使是从下方开始的第一个圆圈,也没有检测到触碰,触碰也在没有圆圈可拨的地方工作。下面我发布了我正在使用的代码 - (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event { CGPoint point = [touch locationInView:self]; if
目前,当我拨键盘时,它只是显示动画,它只是带着动画返回。即使是从下方开始的第一个圆圈,也没有检测到触碰,触碰也在没有圆圈可拨的地方工作。下面我发布了我正在使用的代码
- (BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
CGPoint point = [touch locationInView:self];
if (self.interactionStyle == MHRotaryKnobInteractionStyleRotating)
{
// If the touch is too close to the center, we can't calculate a decent
// angle and the knob becomes too jumpy.
if ([self squaredDistanceToCenter:point] < MinDistanceSquared)
return NO;
// Calculate starting angle between touch and center of control.
_angle = [self angleBetweenCenterAndPoint:point];
}
else
{
_touchOrigin = point;
_angle = [self angleForValue:self.value];
}
self.highlighted = YES;
[self showHighlighedKnobImage];
_canReset = NO;
return YES;
}
- (BOOL)handleTouch:(UITouch *)touch
{
if (touch.tapCount > 1 && self.resetsToDefault && _canReset)
{
[self setValue:self.defaultValue animated:YES];
return NO;
}
CGPoint point = [touch locationInView:self];
if (self.interactionStyle == MHRotaryKnobInteractionStyleRotating)
{
if ([self squaredDistanceToCenter:point] < MinDistanceSquared)
return NO;
// Calculate how much the angle has changed since the last event.
float newAngle = [self angleBetweenCenterAndPoint:point];
float delta = newAngle - _angle;
_angle = newAngle;
// We don't want the knob to jump from minimum to maximum or vice versa
// so disallow huge changes.
if (fabsf(delta) > 45.0f)
return NO;
self.value += (self.maximumValue - self.minimumValue) * delta / (MaxAngle*2.0f);
// Note that the above is equivalent to:
//self.value += [self valueForAngle:newAngle] - [self valueForAngle:angle];
}
else
{
self.value = [self valueForPosition:point];
}
return YES;
}
- (BOOL)continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
if ([self handleTouch:touch] && self.continuous)
[self sendActionsForControlEvents:UIControlEventValueChanged];
return YES;
}
- (void)endTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event
{
self.highlighted = NO;
[self showNormalKnobImage];
// You can only reset the knob's position if you immediately stop dragging
// the knob after double-tapping it, i.e. when tracking ends.
_canReset = YES;
[self handleTouch:touch];
[self sendActionsForControlEvents:UIControlEventValueChanged];
[self setValue:self.defaultValue animated:YES];
}
-(BOOL)开始触摸:(UITouch*)触摸事件:(UIEvent*)事件
{
CGPoint point=[触摸位置查看:自];
if(self.interactionStyle==mRotaryKnobinInteractionStyleRotating)
{
//如果触摸太靠近中心,我们无法计算出合适的距离
//角度和旋钮变得过于跳动。
if([自平方距离中心:点]1&&self.resetsToDefault&&u canReset)
{
[self-setValue:self.defaultValue:是];
返回否;
}
CGPoint point=[触摸位置查看:自];
if(self.interactionStyle==mRotaryKnobinInteractionStyleRotating)
{
if([自平方距离中心:点]45.0f)
返回否;
自我价值+=(自我价值最大值-自我价值最小值)*增量/(最大角度*2.0f);
//请注意,上述内容相当于:
//self.value+=[self-valueForAngle:newAngle]-[self-valueForAngle:angle];
}
其他的
{
self.value=[self-valueForPosition:point];
}
返回YES;
}
-(BOOL)使用触摸继续跟踪:(UITouch*)触摸事件:(UIEvent*)事件
{
if([自手触摸:触摸]&自连续)
[控制事件的自发送操作:UIControlEventValueChanged];
返回YES;
}
-(void)endTrackingWithTouch:(UITouch*)TouchWithEvent:(UIEvent*)事件
{
self.highlighted=否;
[自我表现];
//如果立即停止拖动,则只能重置旋钮的位置
//双击旋钮后,即跟踪结束时,将其打开。
_canReset=是;
[自手触摸:触摸];
[控制事件的自发送操作:UIControlEventValueChanged];
[self-setValue:self.defaultValue:是];
}
我正在努力实现选择拨号的圆圈能够被检测到,并且只有圆圈可以用来拨号,而不是在圆圈之外。提前感谢,感谢您提供的任何帮助。稍加调整,这就是您需要的:
链接:是否没有代码?你还没有发布任何code@AhmedZ. 你刚才发帖的时候真的忘了。哈,完全是想建议这个。