Skip to content
This repository has been archived by the owner on Jan 14, 2021. It is now read-only.

Commit

Permalink
Merge branch 'unromanticman-patch-1' into 1.5.2-development
Browse files Browse the repository at this point in the history
* unromanticman-patch-1:
  add  gifWithURL
  • Loading branch information
bahlo committed Jan 28, 2016
2 parents 3736466 + e59c11d commit 2d5e521
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions SwiftGifCommon/UIImage+Gif.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,20 @@ extension UIImage {
return UIImage.animatedImageWithSource(source)
}

public class func gifWithURL(gifUrl:String) -> UIImage? {

guard let bundleURL:NSURL? = NSURL(string: gifUrl)
else {
print("SwiftGif: This image named \"\(gifUrl)\" does not exist")
return nil
}
guard let imageData = NSData(contentsOfURL: bundleURL!) else {
print("SwiftGif: Cannot turn image named \"\(gifUrl)\" into NSData")
return nil
}
return gifWithData(imageData)
}

public class func gifWithName(name: String) -> UIImage? {
guard let bundleURL = NSBundle.mainBundle().URLForResource(name, withExtension: "gif") else {
print("SwiftGif: This image named \"\(name)\" does not exist")
Expand Down

0 comments on commit 2d5e521

Please sign in to comment.