ios - Animating UIImageView with colorWithPatternImage -


i have uiimageview animated using following code:

    nsmutablearray *imagearray = [[nsmutablearray alloc] init];      for(int = 1; < 15; i++) {         nsstring *str = [nsstring stringwithformat:@"marker_%i.png", i];         uiimage *img = [uiimage imagenamed:str];         if(img != nil) {             [imagearray addobject:img];         }      }      _imagecontainer.animationimages = imagearray;      _imagecontainer.animationduration = 0.5f;     [_imagecontainer startanimating]; 

what want repeat image pattern. there colorwithpatternimage, isn't made animations.

i want whole background filled animated pattern. instead of using large images (960x640) use image of 64x64 example , repeat fill screen.

is there way?

leave code is, instead using uiimageview use subclass:

// //  animatedpatternview.h //  #import <uikit/uikit.h>  @interface animatedpatternview : uiimageview;     @end 

// //  animatedpatternview.m //  #import "animatedpatternview.h"  @implementation animatedpatternview  -(void)setanimationimages:(nsarray *)imagearray {     nsmutablearray* array = [nsmutablearray arraywithcapacity:imagearray.count];      (uiimage* image in imagearray) {         uigraphicsbeginimagecontextwithoptions(self.bounds.size, yes, 0);         uicolor* patterncolor = [uicolor colorwithpatternimage:image];         [patterncolor setfill];         cgcontextref ctx = uigraphicsgetcurrentcontext();         cgcontextfillrect(ctx, self.bounds);         uiimage *img = uigraphicsgetimagefromcurrentimagecontext();         uigraphicsendimagecontext();         [array addobject:img];      }     [super setanimationimages:array]; }  @end 

if create view using interface builder need set class of image view in identity inspector.


Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -