在transitionFromView期间缩放UIView?

发布于 2024-11-01 01:12:41 字数 530 浏览 0 评论 0原文

我使用容器 UIView 来复制 iTunes 商店在您点击专辑插图时的行为,它会翻转和缩放。

当前代码如下所示:

//mainView is 300x300x, smallView is 30x30      

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView transitionFromView:mainView toView:smallView duration:3.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];

containerView.frame = CGRectMake(275, 415, 30, 30);

[UIView commitAnimations];  

我似乎无法在动画过程中缩放 containerView 的内容,框架只是靠近内容。我尝试对视图和图层以及其他一些东西应用一些转换,但我似乎无法让它正常运行。

I'm using a container UIView to replicate the kind of behavior the iTunes store does when you tap on album artwork and it flips and scales.

Current code looks like:

//mainView is 300x300x, smallView is 30x30      

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView transitionFromView:mainView toView:smallView duration:3.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];

containerView.frame = CGRectMake(275, 415, 30, 30);

[UIView commitAnimations];  

I can't seem to get the content of the containerView to scale during the animation, the frame just closes in on the content. I tried applying some transforms to both the view and the layers and a bunch of other things but I can't seem to get it to behave properly.

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

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

发布评论

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

评论(2

你げ笑在眉眼 2024-11-08 01:12:41

不要设置框架,而是尝试使用变换:

- (void)setStartTransform:(CGAffineTransform)transform;
- (void)setEndTransform:(CGAffineTransform)transform;

类似的东西

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView transitionFromView:mainView toView:smallView duration:3.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];

//containerView.frame = CGRectMake(275, 415, 30, 30);

[containerView setStartTransform: CGAffineTransformIdentity];
[containerView setEndTransform: CGAffineTransformMakeScale(0.1, 0.1)];

[UIView commitAnimations];  

(您可能也需要对变换应用翻译。)

Rather than setting the frame, try using a transform instead:

- (void)setStartTransform:(CGAffineTransform)transform;
- (void)setEndTransform:(CGAffineTransform)transform;

Something like

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:2.0];
[UIView transitionFromView:mainView toView:smallView duration:3.0 options:UIViewAnimationOptionTransitionFlipFromLeft completion:nil];

//containerView.frame = CGRectMake(275, 415, 30, 30);

[containerView setStartTransform: CGAffineTransformIdentity];
[containerView setEndTransform: CGAffineTransformMakeScale(0.1, 0.1)];

[UIView commitAnimations];  

(You might need to apply a translate to the transform too.)

预谋 2024-11-08 01:12:41

试试这样:

[UIView transitionWithView:mainView
           duration:0.2
           options:UIViewAnimationOptionTransitionFlipFromLeft
           animations:^{ 
              containerView.frame = CGRectMake(275, 415, 30, 30)
            }
           completion:NULL];

Try it this way:

[UIView transitionWithView:mainView
           duration:0.2
           options:UIViewAnimationOptionTransitionFlipFromLeft
           animations:^{ 
              containerView.frame = CGRectMake(275, 415, 30, 30)
            }
           completion:NULL];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文