Me gustaría presentar una vista de la misma manera que la de UIAlertView - un pop/spring. Desafortunadamente, subclasificar UIAlertView no es una opción para la vista que necesito presentar. He escrito un código, pero parece que no puedo obtenerlo tan realista como me gustaría. Agradecería cualquier sugerencia para un mayor realismo o un enlace si se hubiera hecho algo similar (no pude encontrar nada en Google). Gracias.Creando una animación Pop similar a la presentación de UIAlertView
- (id)initWithFrame:(CGRect)frame {
if ((self = [super initWithFrame:frame])) {
self.backgroundColor = [UIColor whiteColor];
v = [[UIView alloc] initWithFrame:CGRectMake(140, 140, 60, 60)];
v.backgroundColor = [UIColor blueColor];
[self addSubview:v];
[self animate];
}
return self;
}
- (void)animate {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:0.2];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(popStep1Complete)];
v.frame = CGRectMake(90, 90, 140, 140);
[UIView commitAnimations];
}
- (void)popStep1Complete {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:0.15];
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(popStep2Complete)];
v.frame = CGRectMake(110, 110, 100, 100);
[UIView commitAnimations];
}
- (void)popStep2Complete {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationDuration:0.15];
v.frame = CGRectMake(100, 100, 120, 120);
[UIView commitAnimations];
}
¿A dónde va esto? En mi vista principal o mi UIAlertView? – Moshe
Cualquier subclase de 'UIView'. En este caso, la clase personalizada 'UIAlertView'. – zoul
La segunda vez que la animación no se activó, la configuración de la clave nil me solucionó el problema: [auto.view.layer addAnimation: animation forKey: nil]; – amleszk