#import <Foundation/Foundation.h>
@interface MySlider : UISlider {
}
@end
#import "MySlider.h"
@implementation MySlider
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
return self;
}
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
CGRect t = [self trackRectForBounds: [self bounds]];
float v = [self minimumValue] + ([[touches anyObject] locationInView: self].x - t.origin.x - 4.0) * (([self maximumValue]-[self minimumValue]) / (t.size.width - 8.0));
[self setValue: v];
[super touchesBegan: touches withEvent: event];
}
@end