Tengo una UIView que configuré para responder a los gestos de pellizco y cambiar su tamaño, excepto que, una vez que la agranda y luego intenta pellizcarla nuevamente, salta a su tamaño original (que resulta ser 100x200). Aquí está el código:CGAffineTransformMakeScale hace que UIView salte al tamaño del original antes de la escala
@implementation ChartAxisView
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
// do gesture recognizers
UIPinchGestureRecognizer *pinch = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(onPinch:)];
[self addGestureRecognizer:pinch];
[pinch release];
}
return self;
}
- (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGColorRef redColor = [UIColor colorWithRed:1.0 green:0.0 blue:0.0 alpha:1.0].CGColor;
CGContextSetFillColorWithColor(context, redColor);
CGContextFillRect(context, self.bounds);
}
- (void)onPinch: (UIPinchGestureRecognizer*) gesture {
self.transform = CGAffineTransformMakeScale(gesture.scale, gesture.scale);
}
- (void)dealloc {
[super dealloc];
}
@end
¿Alguna idea?
Además, el tamaño automáticamente hará que las restricciones a interferir con la posición, incluso si se usa 'CAAffineTransformScale'. –