登录 立即注册
金钱:

Code4App-iOS开发-iOS 开源代码库-iOS代码实例搜索-iOS特效示例-iOS代码例子下载-Code4App.com

【Swift】Vulcan

来自: Torr 分类: iOS精品源码 上传时间: 2016-11-24 11:53:27

项目介绍:

Vulcan

https://github.com/jinSasaki/Vulcan

Multi image downloader with priority in Swift
Swift多图片下载器

Features 功能

  • Very light
    1、轻量级

  • Multi image download with priority
    2、具有优先级的多图像下载

  • Caching images
    3、图片缓存

  • Pure Swift
    4、纯Swift开发

  • Composable image
    5、可组合图像

  • Support webp

  • Now supported by Carthage only. See SwiftWebP.

Single downloadMulti download with priority
demo_01demo_02

Installation

CocoaPods

Setup CocoaPods:

$ gem install cocoapods

CocoaPods 1.1.0+ is required to build Vulcan

Podfile

platform :ios, '8.0'
use_frameworks!

target '<Your Target Name>' do
pod 'Vulcan'
end

Then, run the following command:

$ pod install

Carthage

Setup carthage:

$ brew update
$ brew install carthage

Cartfile

github "jinSasaki/Vulcan"

Usage

Image downloading and show

import Vulcan

// Single downloading
imageView.vl_setImage(url: URL(string: "/path/to/image")!)

// Multi downloading
// This image will be overridden by the image of higher priority URL.
imageView.vl_setImage(urls: [
    .url(URL(string: "/path/to/image")!, priority: 100),
    .url(URL(string: "/path/to/image")!, priority: 1000)
    ])

WebP image

Add SwiftWebP.framework.

import Vulcan
import SwiftWebP

extension WebPDecoder: ImageDecoder {
    public func decode(data: Data, response: HTTPURLResponse, options: ImageDecodeOptions?) throws -> Image {
        let contentTypes = response.allHeaderFields.filter({ ($0.key as? String ?? "").lowercased() == "content-type" })
        guard
            let contentType = contentTypes.first,
            let value = contentType.value as? String,
            value == "image/webp",
            let image = WebPDecoder.decode(data) else {
                return try DefaultImageDecoder().decode(data: data, response: response, options: options)
        }
        return image
    }
}

// Set decoder to shared ImageDownloader
UIImageView.vl_sharedImageDownloader.decoder = WebPDecoder()

// Request image with URL
imageView.vl_setImage(url: URL(string: "/path/to/image")!)

Requirements 环境需求

  • iOS 8.0+

  • Xcode 8.1+

  • Swift 3.0.1+

code4app

相关源码推荐:

我来说两句
*滑动验证:
所有评论(5)
littleRed 2016-11-25 12:00:07
支持,感谢,祝code4app越来越好~
回复
AlonMessi 2016-11-25 12:03:25
相当不错,感谢无私分享精神!
回复
BlueManlove 2016-11-25 12:10:11
感谢分享,楼主V5~
回复
kengsir 2016-11-25 12:14:30
code4app确实是个好地方,必须支持~
回复
hellokenken 2016-11-25 12:24:02
写的真的很不错
回复
phoiu 2016-11-25 12:51:17
帮帮顶顶!!
回复
提取码:  下载次数:0 状态:您未购买 售价:0(原价:10)金钱 下载权限:初级码农 
230 0 0
联系我们
首页/微信公众账号投稿

帖子代码编辑/版权问题

QQ:435399051,742864542

如何获得代码达人称号?

代码贡献英雄榜
用户名 下载数
通过邮件订阅最新 Code4App 信息
上一条 /4 下一条
联系我们
关闭
合作电话:
13802416937
Email:
435399051@qq.com
商务市场合作/投稿
问题反馈及帮助
联系我们

广告投放| Github|申请友链|手机版|Code4App ( 粤ICP备15117877号-1 )

快速回复 返回顶部 返回列表