The app moves animations dynamically for the app's function
Current version of SDK 8.4 Xcode
Run Xcode Select Create a new Xcode project->single View application named Movingimage
(1) Open viewcontroller.m file in Xcode
(Red is the added code)
#import "ViewController.h"
@interface viewcontroller ()
@end
@implementation Viewcontroller
-(void) viewdidload {
//[super Viewdidload];
additional setup after loading the view, typically from a nib.
Define the position and size of the picture, Position: x=10.0f, y=10.0f, size: x=50.0f, y=40.0f
uiimageview *subview = [[uiimageview alloc]initwithframe:cgrectmake( 10.0f, 10.0f, 50.0f, 40.0f)];
//Set picture name, lovely mouse.png already exists, drag and drop add picture file to project supporting files folder
[SubView setimage: [UIImage imagenamed:@ "lovely mouse.png"];
//Enable animation movement
[uiimageview beginanimations:nil context:NULL];
//Move time 4 seconds
[uiimageview setanimationduration:4];
//Picture continues to move
[uiimageview setanimationbeginsfromcurrentstate:YES];
//redefine the position and size of the picture, position
SubView. frame = cgrectmake(100.0, 150.0, 200.0, 160.0);
//Finish animation move
[uiimageview commitanimations];
//Add a picture to the View subview
[self. View addsubview: SubView];
}
-(void) didreceivememorywarning {
[Super didreceivememorywarning];
//Dispose of any resources, can be recreated.
}
@end
(6) Simulator
This article originated from the online blog tutorial, after I modified and tested. Original Blog Address http://blog.sina.com.cn/s/blog_5fae23350100dvx9.html
Third, image mobile "Apple iOS example Programming primer"