This commit is contained in:
lianxiang
2018-09-26 00:33:06 +08:00
parent 69522b22fc
commit d0230f55ed
68 changed files with 1599 additions and 209 deletions
@@ -8,6 +8,14 @@
#import "NYSliderPopover.h"
#import "NYPopover.h"
#define thumbBound_x 10
#define thumbBound_y 20
@interface NYSliderPopover()
{
CGRect _lastBounds;
}
@end
@implementation NYSliderPopover
@@ -183,4 +191,55 @@
}
// 扩大thumb 触控区域
- (CGRect)thumbRectForBounds:(CGRect)bounds trackRect:(CGRect)rect value:(float)value
{
rect.origin.x = rect.origin.x;
rect.size.width = rect.size.width ;
CGRect result = [super thumbRectForBounds:bounds trackRect:rect value:value];
_lastBounds = result;
return result;
}
- (UIView *)hitTest:(CGPoint)point withEvent:(UIEvent *)event{
UIView *result = [super hitTest:point withEvent:event];
if (point.x < 0 || point.x > self.bounds.size.width){
return result;
}
if ((point.y >= -thumbBound_y) && (point.y < _lastBounds.size.height + thumbBound_y)) {
float value = 0.0;
value = point.x - self.bounds.origin.x;
value = value/self.bounds.size.width;
value = value < 0? 0 : value;
value = value > 1? 1: value;
value = value * (self.maximumValue - self.minimumValue) + self.minimumValue;
[self setValue:value animated:YES];
}
return result;
}
- (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event{
BOOL result = [super pointInside:point withEvent:event];
if (!result && point.y > -10) {
if ((point.x >= _lastBounds.origin.x - thumbBound_x) && (point.x <= (_lastBounds.origin.x + _lastBounds.size.width + thumbBound_x)) && (point.y < (_lastBounds.size.height + thumbBound_y))) {
result = YES;
}
}
return result;
}
@end