Skip to content

Commit 446b689

Browse files
authored
Merge pull request #2 from eduardourso/feature/update-for-xcode8
Swift 3 support
2 parents d9a28a3 + 6b817bb commit 446b689

File tree

53 files changed

+858
-2663
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+858
-2663
lines changed

.swift-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.0

Example/GIFGenerator.xcodeproj/project.pbxproj

Lines changed: 62 additions & 79 deletions
Large diffs are not rendered by default.

Example/GIFGenerator.xcodeproj/xcshareddata/xcschemes/GIFGenerator-Example.xcscheme

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "0720"
3+
LastUpgradeVersion = "0800"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"

Example/GIFGenerator/AppDelegate.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,30 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1414
var window: UIWindow?
1515

1616

17-
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
17+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
1818
// Override point for customization after application launch.
1919
return true
2020
}
2121

22-
func applicationWillResignActive(application: UIApplication) {
22+
func applicationWillResignActive(_ application: UIApplication) {
2323
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
2424
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
2525
}
2626

27-
func applicationDidEnterBackground(application: UIApplication) {
27+
func applicationDidEnterBackground(_ application: UIApplication) {
2828
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
2929
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
3030
}
3131

32-
func applicationWillEnterForeground(application: UIApplication) {
32+
func applicationWillEnterForeground(_ application: UIApplication) {
3333
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
3434
}
3535

36-
func applicationDidBecomeActive(application: UIApplication) {
36+
func applicationDidBecomeActive(_ application: UIApplication) {
3737
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
3838
}
3939

40-
func applicationWillTerminate(application: UIApplication) {
40+
func applicationWillTerminate(_ application: UIApplication) {
4141
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
4242
}
4343

Example/GIFGenerator/Base.lproj/Main.storyboard

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
1-
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
2-
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="9532" systemVersion="15D21" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" initialViewController="MIE-xe-DLg">
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="12120" systemVersion="16E195" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="MIE-xe-DLg">
3+
<device id="retina4_7" orientation="portrait">
4+
<adaptation id="fullscreen"/>
5+
</device>
36
<dependencies>
4-
<deployment identifier="iOS"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="9530"/>
7+
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="12088"/>
8+
<capability name="Constraints to layout margins" minToolsVersion="6.0"/>
9+
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
610
</dependencies>
711
<scenes>
812
<!--Navigation Controller-->
@@ -30,45 +34,61 @@
3034
<viewControllerLayoutGuide type="bottom" id="2fi-mo-0CV"/>
3135
</layoutGuides>
3236
<view key="view" contentMode="scaleToFill" id="kh9-bI-dsS">
33-
<rect key="frame" x="0.0" y="0.0" width="600" height="600"/>
37+
<rect key="frame" x="0.0" y="0.0" width="375" height="667"/>
3438
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
3539
<subviews>
3640
<view contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="n8q-tK-TLU">
37-
<rect key="frame" x="180" y="452" width="240" height="128"/>
41+
<rect key="frame" x="67.5" y="519" width="240" height="128"/>
3842
<subviews>
3943
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="Fw5-7A-bTw">
4044
<rect key="frame" x="14" y="49" width="109" height="30"/>
45+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
4146
<state key="normal" title="Gif from images"/>
4247
<connections>
4348
<action selector="gifFromImages:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="sUU-T3-Ziw"/>
4449
</connections>
4550
</button>
4651
<button opaque="NO" contentMode="scaleToFill" fixedFrame="YES" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="JY2-OQ-JBs">
4752
<rect key="frame" x="129" y="49" width="97" height="30"/>
53+
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
4854
<state key="normal" title="Gif from video"/>
4955
<connections>
5056
<action selector="gifFromVideo:" destination="vXZ-lx-hvc" eventType="touchUpInside" id="5U5-Qk-DtJ"/>
5157
</connections>
5258
</button>
5359
</subviews>
54-
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
60+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
5561
<constraints>
5662
<constraint firstAttribute="width" constant="240" id="Yn8-0N-Xdw"/>
5763
<constraint firstAttribute="height" constant="128" id="b7T-eV-BWQ"/>
5864
</constraints>
5965
</view>
66+
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Result path" textAlignment="center" lineBreakMode="tailTruncation" numberOfLines="0" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="9H4-Ez-jVk">
67+
<rect key="frame" x="16" y="64" width="343" height="455"/>
68+
<fontDescription key="fontDescription" type="system" pointSize="17"/>
69+
<nil key="textColor"/>
70+
<nil key="highlightedColor"/>
71+
</label>
6072
</subviews>
61-
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="calibratedWhite"/>
73+
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
6274
<constraints>
75+
<constraint firstItem="9H4-Ez-jVk" firstAttribute="leading" secondItem="kh9-bI-dsS" secondAttribute="leadingMargin" id="1n5-iA-E30"/>
76+
<constraint firstAttribute="trailingMargin" secondItem="9H4-Ez-jVk" secondAttribute="trailing" id="7mN-YY-voi"/>
6377
<constraint firstItem="n8q-tK-TLU" firstAttribute="centerX" secondItem="kh9-bI-dsS" secondAttribute="centerX" id="9ak-VK-cTb"/>
6478
<constraint firstAttribute="bottom" secondItem="n8q-tK-TLU" secondAttribute="bottom" constant="20" symbolic="YES" id="ECx-mq-VDq"/>
79+
<constraint firstItem="n8q-tK-TLU" firstAttribute="top" secondItem="9H4-Ez-jVk" secondAttribute="bottom" id="Mjy-j6-Jzz"/>
80+
<constraint firstItem="n8q-tK-TLU" firstAttribute="top" secondItem="9H4-Ez-jVk" secondAttribute="bottom" id="dKJ-Fn-Aw6"/>
81+
<constraint firstItem="9H4-Ez-jVk" firstAttribute="top" secondItem="jyV-Pf-zRb" secondAttribute="bottom" id="yLr-01-hHA"/>
6582
</constraints>
6683
</view>
6784
<navigationItem key="navigationItem" id="Hfg-49-FN3"/>
85+
<connections>
86+
<outlet property="resultLabel" destination="9H4-Ez-jVk" id="RF1-26-hxP"/>
87+
</connections>
6888
</viewController>
6989
<placeholder placeholderIdentifier="IBFirstResponder" id="x5A-6p-PRh" sceneMemberID="firstResponder"/>
7090
</objects>
71-
<point key="canvasLocation" x="638" y="192"/>
91+
<point key="canvasLocation" x="637.60000000000002" y="191.1544227886057"/>
7292
</scene>
7393
</scenes>
7494
</document>

Example/GIFGenerator/ViewController.swift

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -8,53 +8,47 @@
88

99
import UIKit
1010
import GIFGenerator
11-
import FLAnimatedImage
1211

1312
class ViewController: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate {
1413

15-
let imageView = FLAnimatedImageView()
14+
@IBOutlet weak var resultLabel: UILabel!
15+
1616
let gifGenerator = GifGenerator()
17+
private let imageView = UIImageView()
1718

1819
let images2:[UIImage] = [UIImage(named: "bart1.jpg")!, UIImage(named: "bart2.jpg")!, UIImage(named: "bart3.jpg")!, UIImage(named: "bart4.jpg")!, UIImage(named: "bart5.jpg")!]
20+
let documentsPath = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)[0]
1921

20-
@IBAction func gifFromImages(sender: AnyObject) {
22+
@IBAction func gifFromImages(_ sender: AnyObject) {
2123
self.generateAnimatedImage(images2)
2224
}
2325

24-
@IBAction func gifFromVideo(sender: AnyObject) {
26+
@IBAction func gifFromVideo(_ sender: AnyObject) {
2527
self.generateAnimatedGifFromVideo()
2628
}
2729

28-
override func viewDidLoad() {
29-
super.viewDidLoad()
30-
self.view.addSubview(self.imageView)
31-
}
32-
33-
func generateAnimatedImage(imageArray: [UIImage]) {
34-
35-
let documentsPath : String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)[0]
36-
let destinationPath :String = documentsPath.stringByAppendingString("/animated.gif")
30+
func generateAnimatedImage(_ imageArray: [UIImage]) {
31+
32+
let destinationPath = documentsPath + "/imageAnimated.gif"
3733

38-
gifGenerator.generateGifFromImages(imagesArray: imageArray, frameDelay: 0.5, destinationURL: NSURL(fileURLWithPath: destinationPath), callback: { (data, error) -> () in
39-
let image = FLAnimatedImage(animatedGIFData: data)
40-
self.imageView.animatedImage = image
41-
self.imageView.frame = CGRectMake(0, 0, image.size.width/2, image.size.height/2)
42-
self.imageView.center = self.view.center
34+
gifGenerator.generateGifFromImages(imagesArray: imageArray, frameDelay: 0.5, destinationURL: URL(fileURLWithPath: destinationPath), callback: { (data, error) -> () in
35+
print("Gif generated under \(destinationPath)")
36+
DispatchQueue.main.async {
37+
self.resultLabel.text = "Gif generated under \(destinationPath)"
38+
}
4339
})
4440
}
4541

4642
func generateAnimatedGifFromVideo() {
43+
44+
let destinationPath = documentsPath + "/videoAnimated.gif"
4745

48-
let documentsPath : String = NSSearchPathForDirectoriesInDomains(.DocumentDirectory,.UserDomainMask,true)[0]
49-
let destinationPath :String = documentsPath.stringByAppendingString("/animated.gif")
50-
51-
if let url = NSBundle.mainBundle().URLForResource("myvideo", withExtension: "mp4"){
46+
if let url = Bundle.main.url(forResource: "myvideo", withExtension: "mp4") {
5247

53-
gifGenerator.generateGifFromVideoURL(videoURL: url, framesInterval: 10, frameDelay: 0.2, destinationURL: NSURL(fileURLWithPath: destinationPath), callback: { (data, error) -> () in
54-
if let image = FLAnimatedImage(animatedGIFData: data) {
55-
self.imageView.animatedImage = image
56-
self.imageView.frame = CGRectMake(0, 0, image.size.width, image.size.height)
57-
self.imageView.center = self.view.center
48+
gifGenerator.generateGifFromVideoURL(videoURL: url, framesInterval: 10, frameDelay: 0.2, destinationURL: URL(fileURLWithPath: destinationPath), callback: { (data, error) -> () in
49+
print("Gif generated under \(destinationPath)")
50+
DispatchQueue.main.async {
51+
self.resultLabel.text = "Gif generated under \(destinationPath)"
5852
}
5953
})
6054
} else {

Example/Podfile

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,7 @@
11
source 'https://github.com/CocoaPods/Specs.git'
2+
platform :ios, '8.0'
23
use_frameworks!
34

4-
target 'GIFGenerator_Example', :exclusive => true do
5+
target 'GIFGenerator_Example' do
56
pod 'GIFGenerator', :path => '../'
6-
pod 'FLAnimatedImage'
7-
end
8-
9-
target 'GIFGenerator_Tests', :exclusive => true do
10-
pod 'GIFGenerator', :path => '../'
11-
12-
137
end

Example/Podfile.lock

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
PODS:
2+
- GIFGenerator (0.2.0)
3+
4+
DEPENDENCIES:
5+
- GIFGenerator (from `../`)
6+
7+
EXTERNAL SOURCES:
8+
GIFGenerator:
9+
:path: ../
10+
11+
SPEC CHECKSUMS:
12+
GIFGenerator: cc64975b1f6fdd9886a0259800d8b4d330781c4b
13+
14+
PODFILE CHECKSUM: a30bc838638cc1baff83cb7cc9587133b7db289a
15+
16+
COCOAPODS: 1.3.0

Example/Pods/FLAnimatedImage/FLAnimatedImage/FLAnimatedImage.h

Lines changed: 0 additions & 82 deletions
This file was deleted.

0 commit comments

Comments
 (0)