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

Commit

Permalink
add gifWithURL
Browse files Browse the repository at this point in the history
  • Loading branch information
yuhsiang237 committed Jan 18, 2016
1 parent eb4ffd2 commit e59c11d
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 e59c11d

Please sign in to comment.