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

时间:2010-08-29 03:49:02

标签: iphone animation uiview transform

以下动画显示屏幕左上角的部分(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。

2 个答案:

答案 0 :(得分:0)

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

摆脱所有-beginAnimations等电话,只需使用:

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

答案 1 :(得分:0)

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

someView.contentMode = UIViewContentModeScaleToFill;

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