标题
#import <Foundation/Foundation.h>
@interface JBSlider : UISlider {
double verticalTouchDelta;
}
@property(nonatomic, assign) double verticalTouchDelta;
@end
主文件
导入“JBSlider.h”
@implementation JBSlider
@synthesize 垂直触摸三角洲;- (void)sendAction:(SEL)action to:(id)target forEvent:(UIEvent *)event{ [super sendAction:action to:target forEvent:event]; //NSLog(@"HI HI");
UITouch * touch = [[event touchesForView:self] anyObject];
//NSLog(@"%f", [touch locationInView:self].y);
verticalTouchDelta = [touch locationInView:self].y;
}
@结尾
只需在 Interface Builder 中将滑块从 UISlider 更改为 JBSlider。效果很棒。