GithubHelp home page GithubHelp logo

alejandro-medici / wturlimageview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from waterlou/wturlimageview

0.0 1.0 0.0 109 KB

UIImageView that get image using AFNetworking with various features.

License: MIT License

wturlimageview's Introduction

WTURLImageView

Introduction

WTURLImageView is a subclass of UIImageView that load images from Internet using AFNetworking, with the following features

  • Auto resize image
  • Show image in different aspect ratio
  • Disk cache using GVCache
  • Activity indicator
  • Placeholder and failed image
  • Various transition animations when image is loaded

Video Demo

screencast

Usage

Simplest call:

[imageView setURL:url];

Call with options:

[imageView setURL:url
		 fillType:fillType
		  options:options
placeholderImage:placeholderImage
     failedImage:failedImage
		   diskCacheTimeoutInternal:diskCacheTimeInterval];

where you can set different fillType:

  • UIImageResizeFillTypeFillIn

  • UIImageResizeFillTypeFitIn

  • UIImageResizeFillTypeIgnoreAspectRatio

  • UIImageResizeFillTypeNoResize

    The class will not rely on the contentMode to set the aspect ratio of the image. It will resize to the size of the imageView unless fillType==UIImageResizeFillTypeNoResize. It is because it is easier to do animation using layer. So you will find that if you set fillType to UIImageResizeFillTypeNoResize, most transiton animations will not run properly.

various options:

  • WTURLImageViewOptionDontUseDiskCache: Disable disk cache
  • WTURLImageViewOptionDontUseConnectionCache: Disable http cache
  • WTURLImageViewOptionDontUseCache: Disable all cache
  • WTURLImageViewOptionDontSaveDiskCache: Don't cache image
  • WTURLImageViewOptionShowActivityIndicator: show activity indicator
  • WTURLImageViewOptionAnimateEvenCache: by default, no animation when load from cache, set it to force animation in all case
  • WTURLImageViewOptionDontClearImageBeforeLoading: by default, will clear old image when loading new image, keep the old image before new image is loaded.
  • WTURLImageViewOptionsLoadDiskCacheInBackground: by default, cache is loaded in foreground. Set it if you assume loading image is very big that will take time to load from cache.
  • WTURLImageViewOptionTransitionXXX: Various predefined transition when image is loaded.

It may be troublesome to set options every time, so you can use a helper class to preset settings:

WTURLImageViewPreset *preset = [][WTURLImageViewPreset alloc] init];
preset.placeholderImage = [UIImage imageNamed:@"placeholder"];

[imageView setURL: url preset:preset];

Or you can set the default settings:

WTURLImageViewPreset *preset = [WTURLImageViewPreset defaultPreset];
preset.placeholderImage = [UIImage imageNamed:@"placeholder"];

that all [WTURLImageView setURL:] will use the preset settings.

Check the sample code for details.

Run the sample code

git clone https://github.com/waterlou/WTURLImageView.git	
cd WTURLImageView	
pod install	
open WTURLImageViewDemo.xcworkspace

License

These specifications and CocoaPods are available under the MIT license.

wturlimageview's People

Contributors

waterlou avatar

Watchers

Alejandro avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.