我正在使用 EVARoundSlider ,它具有带有起点和终点的滑块弧。这使得用户可以顺时针和逆时针旋转滑块。
在 touchesMoved 方法中,我可以在滑块视图中获得第一个角度,最后一个角度和当前角度位置。我希望用户在终点处理程序停止,当它达到360度并且启动点处理程序达到0度时。
// Working Code on circular Slider View
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint location = [touch locationInView:self];
CGFloat fAngle = [self handleAngleByIndex:0];
CGFloat lAngle = [self handleAngleByIndex:1];
int a = AngleFromNorth(_centerPoint, location, SLIDER_FLIPPED);
NSLog(@"First_Angle :%.02f",fAngle);
NSLog(@"last_Angle :%.02f",lAngle);
NSLog(@"Current_Angle :%d",a);
[super touchesMoved:touches withEvent:event];
_dragging = NO;
if (!self.isDragging)
{
if ([self.delegate respondsToSelector:@selector(sliderDraggin:)])
{
[self.delegate sliderDraggin:self];
}
//return;
}
if ([self.delegate respondsToSelector:@selector(sliderDraggin:)])
{
[self.delegate sliderDraggin:self];
}
NSUInteger nearestHandleIndex = [self indexOfNearesPointForTouch:touch];
_nearesHandle = (nearestHandleIndex != NSNotFound) ? _handles[@(nearestHandleIndex)] : nil;
CGFloat d = [_math distanceBetweenPoint:_centerPoint andPoint:location];
CGFloat inOff = _radius - _sliderWidth - _offset.inside;
CGFloat outOff = _radius + _offset.outside;
if (d < inOff || d > outOff)
{
if (self.isNeedToRevoke)
{
_dragging = YES;
return;
}
}
[self.delegate slider:self touchValue:YES atIndex:nearestHandleIndex];
dispatch_async(dispatch_get_main_queue(), ^{
int a = AngleFromNorth(_centerPoint, location, SLIDER_FLIPPED);
[self moveView:_nearesHandle toAngle:a];
[self drawArc];
});
[self informDelegateAboutHandles];
}
如果我尝试为StartAngle和End Angle设置一些条件。在某一点上。它被绞死了,没有什么可以进一步滑动。