12
votes

UIImageView échelle du centre à l'aide de blocs d'animation

J'utilise les éléments suivants pour balancer l'image, mais il est à la mise à l'échelle de son point de haut gauche, comment puis-je faire la balance du centre

[UIView animateWithDuration:duration delay:delay options:options 
                 animations:^{
                     myImageView.frame = frame;
                     myImageView.alpha = alpha;
                 }
                 completion:^(BOOL finished) {

                 }
 ];


0 commentaires

3 Réponses :


2
votes

Ceci peut être le bloc d'animation pour l'échelle de l'image

ici, car laview U peut utiliser l'UIImageView P>

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:GROW_ANIMATION_DURATION_SECONDS];
theView.transform = CGAffineTransformMakeScale(1.2, 1.2);

[UIView commitAnimations];


1 commentaires

Bonjour, merci d'avoir répondu mais je cherche une réponse en termes de nouvelle technique SDK 4 à l'aide de blocs d'animation.



36
votes
[UIView animateWithDuration:0.5 
                      delay:0
                    options:UIViewAnimationOptionBeginFromCurrentState
                 animations:(void (^)(void)) ^{
                     myImageView.transform=CGAffineTransformMakeScale(1.2, 1.2);
                 }
                 completion:^(BOOL finished){
                     myImageView.transform=CGAffineTransformIdentity;
                 }];
this will work perfectly
Good Luck

1 commentaires

Ceci est toujours à l'écoute de la gauche pour moi sous iOS 7.1. Je ne peux pas comprendre ce que je fais mal. Peut-être que c'est autolayout ??



3
votes

Essayez ceci:

[UIView animateWithDuration:2
   animations:^{
       float zoomScal = 5; //want 5x zoom
       CGPoint CenterPoint = CGPointMake(200, 300); // want center point to this
       imgArtifactImage.frame = CGRectMake(- CenterPoint.x * (zoomScal-1),- CenterPoint.y * (zoomScal-1),self.view.frame.size.width * zoomScal,self.view.frame.size.height * zoomScal);
} completion:^(BOOL finished){}];


1 commentaires

Peut-être que ces besoins]; à la fin.