UIImageView 使用动画块从中心缩放

发布于 2024-11-01 23:52:55 字数 353 浏览 5 评论 0原文

我正在使用以下内容来放大图像,但它是从左顶点开始缩放的,如何从中心进行缩放

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

                 }
 ];

I am using the following to scale image up but it's scaling from it's left top point, how can I make the scale from center

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

                 }
 ];

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情绪失控 2024-11-08 23:52:55
[UIView animateWithDuration:0.5 
                      delay:0
                    options:UIViewAnimationOptionBeginFromCurrentState
                 animations:(void (^)(void)) ^{
                     myImageView.transform=CGAffineTransformMakeScale(1.2, 1.2);
                 }
                 completion:^(BOOL finished){
                     myImageView.transform=CGAffineTransformIdentity;
                 }];

这将完美地工作
祝你好运

[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

画骨成沙 2024-11-08 23:52:55

试试这个:

[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){}];

它对我有用。

Try this:

[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){}];

It's working for me.

聽兲甴掵 2024-11-08 23:52:55

这可以是放大图像的动画块

,作为视图 U 可以使用 uiimageview

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

[UIView commitAnimations];

this can be the block of animation for the scale up the image

here as theView U Can Use the uiimageview

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

[UIView commitAnimations];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文