2010-08-29 48 views
3

以下动画的视图到屏幕的左上部分(的ipad):iphone - 动画的图到一个新的宽度和高度

[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。

回答

0

UIView包含CoreAnimation对象(CALayer),这是一个明确的动画:

破除一切-beginAnimations等电话,只是用这个:

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

感谢您的建议。虽然我得到了这个: 错误:访问属性的未知'边界'组件 – sol 2010-08-29 04:18:20

+0

[someView.layer setBounds:CGRectMake(0,0,1024,768)]; 仍然只是将其移动到左上角。不要炸掉它:( – sol 2010-08-29 04:22:50

0

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

someView.contentMode = UIViewContentModeScaleToFill; 

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