Latest 0.0.4
Homepage https://github.com/lYcHeeM/ZJImageBrowser
License MIT
Platforms ios 8.0, requires ARC
Dependencies SDWebImage
Frameworks Photos
Authors

An simple iOS image browser based on UICollectionView written in Swift.

Version

Requirements

  • iOS 8.0+ / macOS 10.10+
  • Xcode 8.0+
  • Swift 3.0+ (You can also use it in Objective-C project.)

Screen shots

SwitchImageDemo
ProgressDemo
3dtouchDemo_1
3dtouchDemo_2
SavingFailedDemo

Usage

Simple

let urlStrings: [String] = [
            "https://wx4.sinaimg.cn/bmiddle/8e88b0c1ly1fh5s967ebdj20j60rpn3l.jpg",
            "https://wx4.sinaimg.cn/bmiddle/0064zot3ly1fds16s02lyj30hs1ysq9h.jpg",
            "https://wx1.sinaimg.cn/bmiddle/8e88b0c1ly1fhai40c5uwg20ax0k04qt.gif",
            "https://wx1.sinaimg.cn/bmiddle/8e88b0c1ly1fh2yxyebfpj20j62bvwrw.jpg",
            "http://ww2.sinaimg.cn/bmiddle/642beb18gw1ep3629gfm0g206o050b2a.gif",
            "https://wx2.sinaimg.cn/bmiddle/0064zot3ly1fds1693k1vj30rs12375r.jpg"
        ]
var imageWrappers = [ZJImageWrapper]()
for urlStr in urlStrings {
    let imageWrapper = ZJImageWrapper(highQualityImageUrl: urlStr, shouldDownloadImage: true, placeholderImage: nil, imageContainer: nil)
    imageWrappers.append(imageWrapper)
}
let browser = ZJImageBrowser(imageWrappers: imageWrappers)
browser.show()

Specify initial image index

let browser = ZJImageBrowser(imageWrappers: imageWrappers, initialIndex: yourSpecifiedInitialIndex)
browser.show()
// Also can: browser.show(at: yourSpecifiedInitialIndex)

Restrict bounds

By default, ZJImageBrowser is full screen displayed. You can also give a rect to make it smaller and show at where you want.

let browser = ZJImageBrowser(imageWrappers: imageWrappers, initialIndex: yourSpecifiedInitialIndex, containerRect: yourSpecifiedRect)
browser.show()

Run the demo project to see other usage, such as 3D Touch support.

Integration

CocoaPods (iOS 8+, OS X 10.9+)

You can use CocoaPods to install ZJImageBrowser by adding it to your Podfile:

platform :ios, '8.0'
use_frameworks!

target 'YourAppTargetName' do
    pod 'ZJImageBrowser', '0.0.4'
end

Requires CocoaPods version 1.0.0+

TODO

  • Support landscape orientation;
  • Complement demo project, providing more detail examples;
  • Pre-download images for indexes other than the initial one.

License

ZJImageBrowser is released under the MIT license. See LICENSE for details.

Latest podspec

{
    "name": "ZJImageBrowser",
    "version": "0.0.4",
    "summary": "An simple iOS photo browser based on UICollectionView written in Swift.",
    "homepage": "https://github.com/lYcHeeM/ZJImageBrowser",
    "license": "MIT",
    "authors": {
        "luozhijun": "[email protected]"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/lYcHeeM/ZJImageBrowser.git",
        "tag": "0.0.4"
    },
    "source_files": "ZJImageBrowser/ZJImageBrowser/*.swift",
    "requires_arc": true,
    "frameworks": "Photos",
    "resource_bundles": {
        "ZJImageBrowser": [
            "Assets/*.png"
        ]
    },
    "xcconfig": {
        "HEADER_SEARCH_PATHS": "$(SDKROOT)/usr/include/libxml2"
    },
    "dependencies": {
        "SDWebImage": [
            "~> 3.7.5"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This