折りたたみアニメーションの UISlider を作成したいと考えています。基本的に、スライダーは、変更中にフルサイズに拡大するタッチされるまで、サムイメージのサイズになります。値を変更してスライダーを離すと、スライダーは元のサイズ (サムネイル画像のサイズ) に戻ります。
touchesBegan と touchesEnd を試してみましたが、あまりうまくいきませんでした。
これまでのところ、UISlider をサブクラス化し、beginTrackingWithTouch と endTrackingWithTouch をオーバーライドしました。このコードの種類は、(もちろんアニメーションなしで) 折りたたみ効果を達成しますが、サム スライダーはもう変化しません。これを行う最善の方法についてのアイデアはありますか?
#import "CollapsingUISlider.h"
@implementation CollapsingUISlider
/*-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
//self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width * 4.0f, self.frame.size.height);
[super touchesBegan:touches withEvent:event];
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event {
// self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, self.frame.size.width * 0.25f, self.frame.size.height);
[super touchesEnded:touches withEvent:event];
}*/
-(BOOL)beginTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, 400, self.frame.size.height);
return YES;
}
-(void)endTrackingWithTouch:(UITouch*)touch withEvent:(UIEvent *)event {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, 20, self.frame.size.height);
}
-(BOOL) continueTrackingWithTouch:(UITouch *)touch withEvent:(UIEvent *)event {
self.frame = CGRectMake(self.frame.origin.x, self.frame.origin.y, 400, self.frame.size.height);
return self.tracking;
}
@end