IOS开发(89)之动画之视图的缩放
1 前言
今天我们学习一下如何为你的视图创建一个仿射缩放变换并使用 uiview 的动画方法来执行缩放变换。
2 代码实例
zyviewcontroller.m:
[plain] - (void)viewdidload
{
[super viewdidload];
// do any additional setup after loading the view, typically from a nib.
uiimage *xcodeimage = [uiimage imagenamed:@"xcode.png"];
self.xcodeimageview = [[uiimageview alloc] initwithimage:xcodeimage];
//设置图片的frame
[self.xcodeimageview setframe:cgrectmake(0.0f,0.0f, 100.0f, 100.0f)];
self.view.backgroundcolor = [uicolor whitecolor];
[self.view addsubview:self.xcodeimageview];
}
- (void) viewdidappear:(bool)paramanimated{ [super viewdidappear:paramanimated];
/* place the image view at the center of the view of this view controller */
self.xcodeimageview.center = self.view.center;
//设置转换标识
self.xcodeimageview.transform = cgaffinetransformidentity;
/* begin the animation */
[uiview beginanimations:nil context:null];
/* make the animation 5 seconds long */
[uiview setanimationduration:5.0f];
//图形放大两倍
self.xcodeimageview.transform = cgaffinetransformmakescale(2.0f, 2.0f);
/* commit the animation */
[uiview commitanimations];
}