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];
}
上一篇: IOS开发(86)之旋转图形
推荐阅读
-
iOS 控件封装(又名拧螺丝)之排序按钮的开发
-
iOS App设计模式开发之适配器模式使用的实战演练
-
IOS开发入门之storyboard的使用
-
IOS开发(38)之Objective-c的@property 详解
-
IOS开发(37)之iphone开发中的delegate
-
IOS开发(41)之关于NSString和NSMutableString的retainCount
-
IOS开发(43)之10个迷惑新手的Cocoa&Objective-c开发问题
-
IOS开发(40)之objective-C 的内存管理之-引用计数
-
IOS开发(59)之Block Object的调用
-
IOS开发(48)之由init、loadView、viewDidLoad、viewDidUnload、dealloc的关系说起