iphone - 将视图动画设置为新的宽度和高度

发布于 2024-09-16 13:16:13 字数 487 浏览 2 评论 0 原文

下面的动画将视图显示在屏幕的左上部分(ipad):

[UIView beginAnimations:@"anim" context:nil];
[UIView setAnimationDuration:5];
[UIView setAnimationDelegate:self];
    someView.frame = CGRectMake(0, 0, 1024, 768);
[UIView commitAnimations];

但是,它不会调整视图的大小(想想我想要炸毁的 UIImageView)。我假设我必须以某种方式通过变换来做到这一点,但我所能想到的就是缩放、旋转和平移(CGAffineTransformMakeRotation、CGAffineTransformMakeScale、CGAffineTransformMakeTranslation)

如何将视图转换为特定的矩形?我不想要只是扩大规模。无论初始大小如何,我都需要将其拉伸到 1024x768。

The following animates a view to the upper left part of the screen (ipad):

[UIView beginAnimations:@"anim" context:nil];
[UIView setAnimationDuration:5];
[UIView setAnimationDelegate:self];
    someView.frame = CGRectMake(0, 0, 1024, 768);
[UIView commitAnimations];

However, it does not resize the view (think of a UIImageView that I want to blow up). I assume I have to do that with a transform somehow, but all I can figure out how to do is scale, rotation, and translation (CGAffineTransformMakeRotation, CGAffineTransformMakeScale, CGAffineTransformMakeTranslation)

How do you transform a view to a specific rectangle? I don't want just a scale up. I need to stretch it to 1024x768, regardless of the intitial size.

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

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

发布评论

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

评论(2

悲凉≈ 2024-09-23 13:16:13

每个 UIView 都包含一个 CoreAnimation 对象 (CALayer),用于显式动画:

摆脱所有 -beginAnimations 等调用,只需使用它:

someView.layer.bounds = CGRectMake(0, 0, 1024, 768);

Every UIView contains a CoreAnimation object (CALayer), which is used for explicit animations:

Get rid of all the -beginAnimations etc calls and just use this:

someView.layer.bounds = CGRectMake(0, 0, 1024, 768);
屌丝范 2024-09-23 13:16:13

您的视图 contentMode 设置为什么?您应该尝试将其设置为:

someView.contentMode = UIViewContentModeScaleToFill;

编辑:确保在动画块之前执行此操作。您应该在 Interface Builder 或视图加载方法之一中设置它:loadView 或 viewDidLoad。

What is your view contentMode set to? You should try setting it to this:

someView.contentMode = UIViewContentModeScaleToFill;

Edit: Make sure you do this before the animation block. You should set it in Interface Builder or in the one the view loading methods: loadView or viewDidLoad.

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