Third, image mobile "Apple iOS example Programming primer"

Source: Internet
Author: User

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"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.