Skip to content

Commit 4e47f78

Browse files
committed
Added example of how to use the library
1 parent 2c9d1af commit 4e47f78

File tree

9 files changed

+61
-7
lines changed

9 files changed

+61
-7
lines changed

Example/GIFGenerator.xcodeproj/project.pbxproj

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@
1313
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDC1AFB9204008FA782 /* Images.xcassets */; };
1414
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 607FACDE1AFB9204008FA782 /* LaunchScreen.xib */; };
1515
607FACEC1AFB9204008FA782 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 607FACEB1AFB9204008FA782 /* Tests.swift */; };
16+
6B4EEBE91C57920A0068B65F /* bart1.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 6B4EEBE41C57920A0068B65F /* bart1.jpg */; };
17+
6B4EEBEA1C57920A0068B65F /* bart2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 6B4EEBE51C57920A0068B65F /* bart2.jpg */; };
18+
6B4EEBEB1C57920A0068B65F /* bart3.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 6B4EEBE61C57920A0068B65F /* bart3.jpg */; };
19+
6B4EEBEC1C57920A0068B65F /* bart4.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 6B4EEBE71C57920A0068B65F /* bart4.jpg */; };
20+
6B4EEBED1C57920A0068B65F /* bart5.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 6B4EEBE81C57920A0068B65F /* bart5.jpg */; };
21+
6B4EEBF01C5792110068B65F /* homer-simpson.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 6B4EEBEE1C5792110068B65F /* homer-simpson.jpg */; };
22+
6B4EEBF11C5792110068B65F /* homer-simpson2.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 6B4EEBEF1C5792110068B65F /* homer-simpson2.jpg */; };
1623
8F4835C86D86CE3FECC93578 /* Pods_GIFGenerator_Tests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D584E3FDD3E9B6854EAE3058 /* Pods_GIFGenerator_Tests.framework */; };
1724
D911E20CF5705AB6B0E7D741 /* Pods_GIFGenerator_Example.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6ABF38B613BDF9820AE724AF /* Pods_GIFGenerator_Example.framework */; };
1825
/* End PBXBuildFile section */
@@ -42,6 +49,13 @@
4249
607FACEA1AFB9204008FA782 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
4350
607FACEB1AFB9204008FA782 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = "<group>"; };
4451
6ABF38B613BDF9820AE724AF /* Pods_GIFGenerator_Example.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_GIFGenerator_Example.framework; sourceTree = BUILT_PRODUCTS_DIR; };
52+
6B4EEBE41C57920A0068B65F /* bart1.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bart1.jpg; sourceTree = "<group>"; };
53+
6B4EEBE51C57920A0068B65F /* bart2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bart2.jpg; sourceTree = "<group>"; };
54+
6B4EEBE61C57920A0068B65F /* bart3.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bart3.jpg; sourceTree = "<group>"; };
55+
6B4EEBE71C57920A0068B65F /* bart4.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bart4.jpg; sourceTree = "<group>"; };
56+
6B4EEBE81C57920A0068B65F /* bart5.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = bart5.jpg; sourceTree = "<group>"; };
57+
6B4EEBEE1C5792110068B65F /* homer-simpson.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "homer-simpson.jpg"; sourceTree = "<group>"; };
58+
6B4EEBEF1C5792110068B65F /* homer-simpson2.jpg */ = {isa = PBXFileReference; lastKnownFileType = image.jpeg; path = "homer-simpson2.jpg"; sourceTree = "<group>"; };
4559
A57E4CE0E041BD4BD2848717 /* Pods-GIFGenerator_Tests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-GIFGenerator_Tests.release.xcconfig"; path = "Pods/Target Support Files/Pods-GIFGenerator_Tests/Pods-GIFGenerator_Tests.release.xcconfig"; sourceTree = "<group>"; };
4660
BA668C8A202735598FA1E753 /* LICENSE */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = LICENSE; path = ../LICENSE; sourceTree = "<group>"; };
4761
BEAECE2072074FF042AF4B20 /* GIFGenerator.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GIFGenerator.podspec; path = ../GIFGenerator.podspec; sourceTree = "<group>"; };
@@ -93,6 +107,7 @@
93107
607FACD21AFB9204008FA782 /* Example for GIFGenerator */ = {
94108
isa = PBXGroup;
95109
children = (
110+
6B4EEBE31C5791580068B65F /* Resources */,
96111
607FACD51AFB9204008FA782 /* AppDelegate.swift */,
97112
607FACD71AFB9204008FA782 /* ViewController.swift */,
98113
607FACD91AFB9204008FA782 /* Main.storyboard */,
@@ -139,6 +154,20 @@
139154
name = "Podspec Metadata";
140155
sourceTree = "<group>";
141156
};
157+
6B4EEBE31C5791580068B65F /* Resources */ = {
158+
isa = PBXGroup;
159+
children = (
160+
6B4EEBEE1C5792110068B65F /* homer-simpson.jpg */,
161+
6B4EEBEF1C5792110068B65F /* homer-simpson2.jpg */,
162+
6B4EEBE41C57920A0068B65F /* bart1.jpg */,
163+
6B4EEBE51C57920A0068B65F /* bart2.jpg */,
164+
6B4EEBE61C57920A0068B65F /* bart3.jpg */,
165+
6B4EEBE71C57920A0068B65F /* bart4.jpg */,
166+
6B4EEBE81C57920A0068B65F /* bart5.jpg */,
167+
);
168+
name = Resources;
169+
sourceTree = "<group>";
170+
};
142171
A9EE472F93660676D01DC08A /* Pods */ = {
143172
isa = PBXGroup;
144173
children = (
@@ -246,9 +275,16 @@
246275
isa = PBXResourcesBuildPhase;
247276
buildActionMask = 2147483647;
248277
files = (
278+
6B4EEBEB1C57920A0068B65F /* bart3.jpg in Resources */,
249279
607FACDB1AFB9204008FA782 /* Main.storyboard in Resources */,
280+
6B4EEBEC1C57920A0068B65F /* bart4.jpg in Resources */,
250281
607FACE01AFB9204008FA782 /* LaunchScreen.xib in Resources */,
282+
6B4EEBE91C57920A0068B65F /* bart1.jpg in Resources */,
251283
607FACDD1AFB9204008FA782 /* Images.xcassets in Resources */,
284+
6B4EEBED1C57920A0068B65F /* bart5.jpg in Resources */,
285+
6B4EEBF01C5792110068B65F /* homer-simpson.jpg in Resources */,
286+
6B4EEBF11C5792110068B65F /* homer-simpson2.jpg in Resources */,
287+
6B4EEBEA1C57920A0068B65F /* bart2.jpg in Resources */,
252288
);
253289
runOnlyForDeploymentPostprocessing = 0;
254290
};

Example/GIFGenerator/ViewController.swift

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,36 @@
77
//
88

99
import UIKit
10+
import GIFGenerator
1011

1112
class ViewController: UIViewController {
13+
14+
let gifGenerator = GifGenerator()
1215

1316
override func viewDidLoad() {
1417
super.viewDidLoad()
15-
// Do any additional setup after loading the view, typically from a nib.
18+
19+
// let images:[UIImage] = [UIImage(named: "homer-simpson.jpg")!, UIImage(named: "homer-simpson2.jpg")!]
20+
let images2:[UIImage] = [UIImage(named: "bart1.jpg")!, UIImage(named: "bart2.jpg")!, UIImage(named: "bart3.jpg")!, UIImage(named: "bart4.jpg")!, UIImage(named: "bart5.jpg")!]
21+
22+
let documentsPath : String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)[0]
23+
if let destinationPath :String = documentsPath.stringByAppendingString("/animated.gif") {
24+
25+
gifGenerator.generateGifFromImages(images2, frameDelay: 0.5, destinationURL: NSURL(fileURLWithPath: destinationPath), callback: { (data, error) -> () in
26+
if error == nil {
27+
if let data = data {
28+
let image = UIImage(data: data)
29+
let imageView = UIImageView(image: image)
30+
imageView.image = image
31+
imageView.frame = CGRectMake(0, 0, image!.size.width/2, image!.size.height/2)
32+
imageView.center = self.view.center
33+
self.view.addSubview(imageView)
34+
}
35+
}
36+
37+
})
38+
39+
}
1640
}
17-
18-
override func didReceiveMemoryWarning() {
19-
super.didReceiveMemoryWarning()
20-
// Dispose of any resources that can be recreated.
21-
}
22-
2341
}
2442

Example/GIFGenerator/bart1.jpg

14.5 KB
Loading

Example/GIFGenerator/bart2.jpg

16.5 KB
Loading

Example/GIFGenerator/bart3.jpg

45.2 KB
Loading

Example/GIFGenerator/bart4.jpg

17.6 KB
Loading

Example/GIFGenerator/bart5.jpg

15.4 KB
Loading
44.9 KB
Loading
68.3 KB
Loading

0 commit comments

Comments
 (0)