Chcel by som animovať škálovanie UIView a všetkého jeho obsahu neblokujúcim spôsobom. Momentálne to robím ...
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.1];
[UIView setAnimationDelegate:self];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
CGAffineTransform transform = CGAffineTransformMakeScale(1.1,1.1);
self.view.transform = transform;
[UIView commitAnimations];
Avšak je to tak blokovanie, Radšej by som použil niečo ako ...
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform = CGAffineTransformMakeScale(1.1,1.1);
self.view.transform = transform;
}];
... ale animateWithDuration nefunguje s transformáciou CALayer / CGAffineTransform. Ako môžem dosiahnuť rovnakú animáciu bez blokovania niečoho?
odpovede:
5 pre odpoveď č. 1skúste použiť:
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform =
CGAffineTransformScale(CGAffineTransformIdentity, 2.0, 2.0);
self.view.transform = transform;
}];
Stačí pridať užitočnú poznámku k tejto skvelej odpovedi, takmer vždy chcete zapnúť rasterizáciu, takže vyzerá hladko
self.view.layer.shouldRasterize = YES;
[UIView animateWithDuration:0.2
animations:^{
CGAffineTransform transform =
CGAffineTransformScale(CGAffineTransformIdentity, 0.5, 0.5);
self.view.transform = transform;
}];