iOS ImageView and fetch file Resources build Dynamic Asuka Chart

Source: Internet
Author: User

Yesterday saw a famous school public class, discuss the significance of university education, feeling quite deep. I think that the most important thing for a domestic university to do with a foreign university is to explore the spirit, and if you can't find what you want in college, you should stay away from college. He will only imprison your thoughts, you should have a wide range of hobbies, cultivate the curiosity of the world. Whether it is animal plants, physical chemistry, music and other arts. To explore things that make people feel incredible 5 years later. Then keep your spirit of discovery alive and shared with more people. It is the source of our strength to maintain physical and mental strength.


Today we will do a very interesting thing, below we build a new project. By the way, this time the file image resources (http://download.csdn.net/detail/wq820203420/8449067) can be downloaded.


#import "ViewController.h"


@interface viewcontroller ()


@end


@implementation Viewcontroller


-(void) viewdidload {

[superviewdidload];


Call the following -(void) Createimageview

[selfcreateimageview];

}


-(void) Createimageview

{

// Create a large background

uiimageview *bgview = [[uiimageviewalloc]< /c16>init];

Bgview. Frame = Self . View . bounds ;

// set picture background

Bgview. Image = [UIImageimagenamed:@ "back2.jpg"];

[self. View addsubview: Bgview];


// fetch file path

nsstring *path = [[nsbundlemainbundle] Pathforresource:@ "DOVE 1"ofType:@ "PNG" ];

UIImage *image1 = [UIImageimagewithcontentsoffile:p Ath] ;

// because Asuka wants to display a carrier, we need to create a ImageViewto carrythe bird

uiimageview *imageview = [[uiimageviewalloc ]init];

// its width is the width of the resource picture, height is the height of the resource picture

ImageView. Frame = CGRectMake (image1 , A. size . width , Image1. size . Height );

// then load the picture onto the created imageview

ImageView. Image = Image1;

[self. View addsubview: ImageView];


// There are many pictures in the resource, then I need to create a dynamic array to store it.

nsmutablearray *imagearray = [nsmutablearrayArray ];

// with a for loop, constant storage

for (int i =1; i<; i++) {

// Create picture name

nsstring *imagename = [nsstringstringWithFormat : @ "DOVE%d" , I];

// Create a Picture object

UIImage *image = [UIImageimagenamed: imageName];

// Save the Picture object in a dynamic array

[Imagearray addobject: image];

}

// to load the image stored in the array into the imageview in an animated form

ImageView. animationimages = Imagearray;

// Set Number of repetitions,0 is infinite

[ImageView setanimationrepeatcount:0];

// set period, the faster the cycle, the faster the bird flies, haha

[ImageView setanimationduration:1];

// turn on animation

[ImageView startanimating];

}


Is he flying? I can't save the dynamic diagram here, I'll cut one for everyone. Below are the and code maps.



iOS ImageView and fetch file Resources build Dynamic Asuka Chart

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.