UI_UIImageView basic operations, ui_uiimageview

Source: Internet
Author: User

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.

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.