Latest 1.0.1
Homepage https://github.com/tzef/BmoImageLoader
License MIT
Platforms ios 9.0
Dependencies AlamofireImage
Frameworks UIKit
Authors

[![CI Status](http://img.shields.io/travis/LEE ZHE YU/BmoImageLoader.svg?style=flat)](https://travis-ci.org/LEE ZHE YU/BmoImageLoader)
Version
License
Platform

BmoImageLoader is a progress animated component for UIImageView

Image downloader implementation and cache manager use AlamofireImage

Feature

  • [x] UIImageView Extension for image downloading with progress animation
  • [x] UIImageView Downloads with placeholder image
  • [x] Shape UIImageView
  • [x] Include 7 style progress animation
  • [x] UIImageView progress animator support custom control, used in any case
  • [x] AlamofireImage default In-Memory Image Cache
  • [x] AlamofireImage default Prioritized Queue Order Image Downloading

Requirements

iOS 8.0+
Xcode 8.0+
Swift 3.0+

Dependencies

Alamofire 4.0+
AlamofireImage 3.1

BmoImageViewFactory

Shape ImageView

Support RoundedRect, Circle, Ellipse, Triangle, Pentagon, Heart, Star totally 7 shape paths

BmoImageViewFactory.shape(UIImageView, shape: BmoImageViewShape)

Create Progress Animator

The factory will return a BmoProgressAnimator Protocol

let animator = BmoImageViewFactory
    .progressAnimation(UIImageView, newImage: nil, style: BmoImageViewProgressStyle)

BmoProgressAnimator default progress TotalUnitCount is 100, if need changed

animator.setTotalUnitCount(count: Int64)

When progress forward

animator.setCompletedUnitCount(count: Int64)

More, you can custom animation detail style

animator.setProgressColor(UIColor)
        .setMarginPercent(percent: CGFloat)
        .setAnimationDuration(duration: NSTimeInterval)

UIImageView Extension

If you want to use more flexible, can use AlamofireImage’s ImageCache and ImageDownloader, custom ImageDownloader.ProgressHandler, catch totalBytesRead and totalExpectedBytesToRead and use BmoImageViewFactory.progressAnimation to display progress animtion

Setting Image with URL

Setting the image with a URL will asynchronously download the image and set it once the request is finished.

imageView.bmo_setImageWithURL(IMAGE_URL)

Run image progress animation if catched

Whether to run the image progress animation if the image is cached. Defaults is false

imageView.bmo_runAnimationIfCatched(true)

Example

Use CirclePie progress style to load a new image without handle downloading progress, just image transition

let placeholderImage = UIImage(named: "placeholder")
let animator = BmoImageViewFactory
    .progressAnimation(UIImageView, newImage: placeholderImage, style: BmoImageViewProgressStyle.CirclePie(borderShape: true))
    .setAnimationDuration(0.5)
    .setCompletionBlock({ (result) in
                        if result.isSuccess {
                            //do something when succeed
                        }
                        if result.isFailure {
                            //do something when failed
                        }
                    })
if let newImage = UIImage(named: "newImage") {
    animator.setNewImage(newImage)
            .setCompletionState(BmoProgressCompletionState.Succeed)
}

Use CircleBrush progress style to upload a new image

use Alamofire Uploading with Progress

Alamofire.upload(.POST, "https://httpbin.org/post", file: fileURL)
         .progress { bytesWritten, totalBytesWritten, totalBytesExpectedToWrite in
             print(totalBytesWritten)

             // This closure is NOT called on the main queue for performance
             // reasons. To update your ui, dispatch to the main queue.
             dispatch_async(dispatch_get_main_queue()) {
                 print("Total bytes written on main queue: (totalBytesWritten)")
             }
         }
         .validate()
         .responseJSON { response in
             debugPrint(response)
         }

And then pass totalBytesWrittenand totalBytesExpectedToWrite to BmoProgressAnimator

let newImage = UIImage(named: "newImage")
let animator = BmoImageViewFactory
    .progressAnimation(UIImageView, newImage: newImage, style: BmoImageViewProgressStyle.CircleBrush(borderShape: true))
    .setTotalUnitCount(totalBytesExpectedToWrite)
    .setCompletionBlock({ (result) in
                        if result.isSuccess {
                            //do something when succeed
                        }
                        if result.isFailure {
                            //do something when failed
                        }
                    })

When uploading

animator.setCompletedUnitCount(totalBytesWritten)

When uploading completed, succeed or failed

animator.setCompletionState(BmoProgressCompletionState.Succeed)

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

BmoImageLoader is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod "BmoImageLoader"

Author

LEE ZHE YU, [email protected]

License

BmoImageLoader is available under the MIT license. See the LICENSE file for more info.

Latest podspec

{
    "name": "BmoImageLoader",
    "version": "1.0.1",
    "summary": "A progress animated component for UIImageView",
    "description": "BmoImageLoader is a progress animated component for UIImageViewnImage downloader implementation and cache manager use AlamofireImage",
    "homepage": "https://github.com/tzef/BmoImageLoader",
    "screenshots": [
        "https://raw.githubusercontent.com/tzef/BmoImageLoader/master/Screenshot/animationStyle.png",
        "https://raw.githubusercontent.com/tzef/BmoImageLoader/master/Screenshot/progressControl.png"
    ],
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "LEE ZHE YU": "[email protected]"
    },
    "source": {
        "git": "https://github.com/tzef/BmoImageLoader.git",
        "tag": "1.0.1"
    },
    "platforms": {
        "ios": "9.0"
    },
    "source_files": "BmoImageLoader/Classes/**/*",
    "frameworks": "UIKit",
    "dependencies": {
        "AlamofireImage": [
            "~> 3.1"
        ]
    },
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This