ViewController.m 2.19 KB
  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
//
// ViewController.m
// AnimatedWebpExample
//
// Created by DongSoo Lee on 2015. 12. 4..
// Copyright © 2015년 DongSoo Lee. All rights reserved.
//

#import "ViewController.h"
#import "UIImage+animatedGIF.m"

@interface ViewController ()

@end

@implementation ViewController

- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.

UIImage *image = [YYImage imageNamed:@"500_1562701_1441589347.webp"];
// NSString *retinaPath = [[NSBundle mainBundle] pathForResource:@"500_1562701_1441589347" ofType:@"gif"];
// NSData *data = [NSData dataWithContentsOfFile:retinaPath];
// UIImage *image = [UIImage animatedImageWithAnimatedGIFData:data];
self.imageView = [[YYAnimatedImageView alloc] initWithImage:image];
self.imageView.frame = CGRectMake(self.imageView.frame.origin.x
, self.imageView.frame.origin.y
, self.view.bounds.size.width
, self.view.bounds.size.width * self.imageView.frame.size.width / self.imageView.frame.size.height);
self.imageView.contentMode = UIViewContentModeScaleAspectFit;
self.imageView.clipsToBounds = YES;
[self.imageView.layer setBorderColor:[[UIColor yellowColor] CGColor]];
[self.imageView.layer setBorderWidth:1];
[self.view addSubview:self.imageView];

UIImage *image2 = [YYImage imageNamed:@"500_1562701_1441589347.gif"];

self.imageView2 = [[YYAnimatedImageView alloc] initWithImage:image2];
self.imageView2.frame = CGRectMake(self.imageView2.frame.origin.x
, self.imageView.frame.origin.y + self.imageView.frame.size.height
, self.view.bounds.size.width
, self.view.bounds.size.width * self.imageView2.frame.size.width / self.imageView2.frame.size.height);
self.imageView2.contentMode = UIViewContentModeScaleAspectFit;
self.imageView2.clipsToBounds = YES;
[self.view addSubview:self.imageView2];
}

- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}

@end