Usando o manipulador de conclusão de blocos no iOS 4 para animação
-
28-09-2019 - |
Pergunta
Gostaria de animar o movimento do meu subviews ao girar o dispositivo, alterar o alfa para 0, mover a vista para a nova posição e redefinir o alfa para 1.
Usando este código em didRotateFromInterfaceOrientation
faz com que a vista pisque e desapareça muito rapidamente e depois reapareça. Eu gostaria de evitar esse comportamento.
[UIView animateWithDuration:kAnimationDuration animations:^{
anObject.alpha = 0.0;
CGRect newFrame = anObject.frame;
newFrame.origin.x = newX;
newFrame.origin.y = newY;
newFrame.size.width = newWidth;
newFrame.size.height = newHeight;
anObject.frame = newFrame;
} completion:^ (BOOL finished){
if (finished) {
anObject.alpha = 1.0;
}
}];
Existe uma maneira de reverter isso piscando?
Obrigado
Solução
Talvez realmente animar o Alpha em compleção? Em vez de piscar? :)
[UIView animateWithDuration:kAnimationDuration animations:^{
anObject.alpha = 0.0;
CGRect newFrame = anObject.frame;
newFrame.origin.x = newX;
newFrame.origin.y = newY;
newFrame.size.width = newWidth;
newFrame.size.height = newHeight;
anObject.frame = newFrame;
} completion:^ (BOOL finished){
if (finished) {
[UIView animateWithDuration:kAnimationDuration
animations:^{
anObject.alpha = 1;}
}
}];
Saúde, Krzysztof Zabłocki
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow