UI_UIImageView basic operations, ui_uiimageview
UI_UIImageView common methods
// Use ImageView to locate the image UIImage * image = [UIImage imageNamed: @ "bg_2"] by name; // Add the image to imageView. UIImageView * imageView = [[UIImageView alloc] initWithImage: image]; // set the image position and size. frame = CGRectMake (40, 40, 90,160); imageView. backgroundColor = [UIColor redColor]; // sets the imageView transparency. alpha = 0.5; // Add a click event for the image // set userInteractionEnabled to YES to respond to the Click Event imageView. userInteractionEnabled = YES; // sets the interaction between images. // sets the UITapGestureRecognizer * singleTag = [[UITapGestureRecognizer alloc] initWithTarget: self action: @ selector (tapImageView :)] // Add gesture [imageView addGestureRecognizer: singleTag]; // display/hide YES to hide imageView. hidden = NO; // obtain the image UIImage * netImage = [UIImage imageWithData: [NSData dataWithContentsOfURL: [NSURL URLWithString: @ "www.google.com"]; // Add the image to the window and release the memory [self. window addSubview: imageView]; [imageView release]; imageView = nil; // safely release
Dynamic Graph
UIImageView * imageView = [[UIImageView alloc] initWithImage: [UIImage imageNamed: @ "1. tiff "]; imageView. frame = CGRectMake (40, 50,100,100); // Add a group of images to the imageView. NSMutableArray * array = [NSMutableArray array]; for (int I = 1; I <5; I ++) {// NSString * name = [NSString stringWithFormat: @ "00% d. tiff ", I]; // UIImage * image = [UIImage imageNamed: name]; // the preceding two sentences can be combined into a UIImage * image = [UIImage imageNamed: [NSString stringWithFormat: @ "% d. tiff ", I]; [array addObject: image];} // put the array in imageView. imageView. animationImages = array; [self addSubview: imageView]; // specifies the playback time. animationDuration = 0.4f; // Number of playback times imageView. animationRepeatCount = 0; // 0 is an infinite number of times // start the animation [imageView startAnimating]; // end the animation] // [imageView stopAnimating];
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.