Vorrei presentare una visualizzazione nello stesso modo di UIAlertView - un pop/spring. Purtroppo la sottoclasse di UIAlertView non è un'opzione per la vista che devo presentare. Ho scritto del codice, ma non riesco a ottenerlo in modo realistico come vorrei. Gradirei qualsiasi suggerimento per un maggiore realismo o un link se qualcosa di simile è stato fatto (non ho trovato nulla su Google). Grazie.Creazione di un'animazione pop simile alla presentazione di 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];
}
Dove va? Nella mia vista genitore o nel mio UIAlertView? – Moshe
Qualsiasi sottoclasse di 'UIView'. In questo caso la classe 'UIAlertView' personalizzata. – zoul
La seconda volta che l'animazione non è stata attivata, l'impostazione di nil key ha risolto il problema per me: [self.view.layer addAnimation: animation forKey: nil]; – amleszk