Ui_uiimageview Common methods
//Use ImageView to find a picture by name UIImage*image = [UIImageimagenamed:@"Bg_2"];//Add image to ImageView Uiimageview*imageview = [[UiimageviewAlloc] initwithimage:image];//Set picture position and sizeImageView. Frame= CGRectMake ( +, +, -, the); ImageView. BackgroundColor= [UicolorRedcolor];//Set TransparencyImageView. Alpha=0.5;//Add a click event for a picture //userinteractionenabled is YES to respond to click eventsImageView. userinteractionenabled=YES;//Set pictures to interact //Set gesturesUITapGestureRecognizer *singletag = [[UITapGestureRecognizer alloc] Initwithtarget: SelfAction@selector(Tapimageview:)];//Add gestures[ImageView Addgesturerecognizer:singletag];//Show/Hide YES to hideImageView. Hidden=NO;//Get pictures from the network UIImage*netimage = [UIImageImagewithdata:[nsdata datawithcontentsofurl:[Nsurlurlwithstring:@"www.google.com"]]];//Add image to window and free memory[ Self. WindowAddsubview:imageview]; [ImageView release]; ImageView =Nil;//Safe release
Dynamic graphs
Uiimageview*imageview = [[UiimageviewAlloc] initwithimage:[UIImageimagenamed:@"1.tiff"]]; ImageView. Frame= CGRectMake ( +, -, -, -);//Add a set of pictures to ImageView Nsmutablearray*array = [NsmutablearrayArray]; for(inti =1; I <5; i++) {//NSString *name = [NSString stringwithformat:@ "00%d.tiff", I];//UIImage *image = [UIImage imagenamed:name]; //The above two sentences can be combined as one sentence UIImage*image = [UIImageimagenamed:[NSStringstringwithformat:@"%d.tiff", I]]; [Array addobject:image]; }//Put the array in the ImageViewImageView. Animationimages= array; [ SelfAddsubview:imageview];//Play TimeImageView. Animationduration=0.4F//Play CountImageView. Animationrepeatcount=0;//0 is an infinite number of times //Start animation[ImageView startanimating];//End Animation "//[ImageView stopanimating];
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Ui_uiimageview Basic Operation