Dock mode + GIF, dock mode gif
UIView * redView = [[UIView alloc] initWithFrame: CGRectMake (200,200,)];
RedView. backgroundColor = [UIColor redColor];
// Allows the sub-view to zoom in or out. The default value of autoresizeSubviews is YES.
RedView. autoresizeSubview = YES;
RedView. tag = 100;
[Self. window addSubview: redView];
UIView * yellowView = [[UIView alloc] initWithFrame: CGRectMake (0,0, 100,100)];
// Zoom in or out at a scalable height
YellowView. autoresizingMask = UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexbleWidth;
YellowView. backgroundColor = [UIColor yellowColor];
[RedView addSubview: yellowView];
UIButton * btn = [UIButton buttonWithType: UIButtonTypeSystem];
[Btn setTitle: @ "zoom in" forState: UIControlStateNormal];
Btn. frame = CGRectMake (100,300,100, 30 );
[Self. window addSubview: btn];
[Btn addTarget: self action: @ selector (btnClick :) forControlEvents: UIControlEventTouchUpInside];
-(Void) btnClick :( UIButton *) bt
{
UIView * redView = [self. window viewWithTag: 100];
RedView. frame = CGRectMake (redView. frame. origin. x, redView. frame. origin. y, redView. frame. size. width + 10, redView. frame. size. height + 10 );
}
// Third-party GIF Library
(1)
// Obtain the image path
NSString * imgPath = [[NSBundle mainBundle] pathForResource: @ "FlagZombie" ofType: @ "gif"];
// Initialize NSData through a file in the specified path
NSData * data = [[NSData alloc] initWithContentOfFile: imgPath];
UIImageView * imgView = [[UIImageView alloc] initWithFrame: CGRectMake (100,100, 50, 50)];
ImgView. image = [UIImage animatedImageWithAnimatedGIFData: data];
[Self. window addSubview: imgView];
(2)
NSURL * url = [[NSBundle mainBundle] URLForResource: @ "FlagZombie" withExtension: @ "gif"];
UIImageView * imgView = [[UIImageView alloc] initWithFrame: CGRectMake (200,100,)];
// Use the method in the category to play the Gif image using the animatedImageWithAnimatedGIFURL Method
ImgView. imge = [UIImage animatedImageWithAnimatedGIFURL: url];
ImgView. tag= 100;
[Self. window addSubview: imgView];
// Call the move method every time using a timer
[NSTimer scheduledTimerWithTimeInterval: 1 target: self selector: @ selector (move) userInfo: nil repeats: YES];
-(Void) move {
UIImageView * imgView = (UIImageView *) [self. window viewWithTag: 100];
// When the x coordinate of the image is greater than 80, move is not called to offset the image to the left by 5 units
If (imgView. frame. origin. x> 80 ){
ImgView. frame = CGRectMake (imgView. frame. origin. x-5, imgView. frame. origin. y, imgView. frame. size. width, imgView. frame. size. height );
}
}