GIF, APNG : SDWebImage 라이브러리 사용
- Pod : pod 'SDWebImage'
- SPM : https://github.com/SDWebImage/SDWebImage
SVG : SVGKit 라이브러리 사용
- Pod : pod 'SVGKit'
- SPM : https://github.com/SVGKit/SVGKit.git
이미지는 앱 번들에 포함
- GIF, APNG : ImageView 를 포함시켜 SDAnimatedImageView 클래스로 지정
- SVG : UIView 를 포함시켜 SVGKFastImageView 클래스로 지정
ViewController.h
#import <UIKit/UIKit.h>
#import "SDWebImage/SDAnimatedImageView.h"
#import "SDWebImage/SDAnimatedImage.h"
#import "SVGKit.h"
#import "SVGKImage.h"
#import "SVGKFastImageView.h"
@interface ViewController : UIViewController
@property (strong, nonatomic) IBOutlet SDAnimatedImageView *imgGif;
@property (strong, nonatomic) IBOutlet SVGKFastImageView *imgSvg;
@property (strong, nonatomic) IBOutlet SDAnimatedImageView *imgApng;
@end
|
cs |
ViewController.m
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
// GIF
NSString *gifPath = [[NSBundle mainBundle] pathForResource:@"gif_sample" ofType:@"gif"];
NSData *gifData = [NSData dataWithContentsOfFile:gifPath];
[self.imgGif setImage:[SDAnimatedImage imageWithData:gifData]];
// SVG
SVGKImage *svgImage = [SVGKImage imageNamed:@"svg_sample.svg"];
[self.imgSvg setImage:svgImage];
// APNG
NSString *apngPath = [[NSBundle mainBundle] pathForResource:@"apng_sample" ofType:@"png"];
NSData *apngData = [NSData dataWithContentsOfFile:apngPath];
[self.imgApng setImage:[SDAnimatedImage imageWithData:apngData]];
}
@end
|
cs |
'IT > Ⅰ. IOS' 카테고리의 다른 글
[IOS] 이미지로 프로그레스바 만들기 (0) | 2025.05.17 |
---|---|
[IOS] PDF 문서 보기 - WKWebView 사용 (0) | 2025.05.11 |
[IOS] PDF 문서 보기 - PDFKit 사용 (0) | 2025.05.10 |