Git Product home page Git Product logo

zsimageview's Introduction

ZSImageView

This is a replacement for UIImageView. Unlike UIImageView, ZSImageView supports loading a remote image as well as providing a default image while the remote image is loading. You can also round any of the edges individually as well as set borders individually.

ZSImageView

How It Works

Create a ZSImageView and set the remote and default image:

ZSImageView *imageView = [[[ZSImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)] autorelease];
imageView.imageUrl = @"http://www.indiaonrent.com/forwards/b/beautiful-mountains/res/593qen.jpg";
imageView.defaultImage = [UIImage imageNamed:@"no-image.png"];
imageView.contentMode = UIViewContentModeScaleAspectFill;
[self.view addSubview:imageView];

If you want to round three of the edges and give the view a cornerRadius of 10 it is pretty easy:

ZSImageView *imageView2 = [[[ZSImageView alloc] initWithFrame:CGRectMake(0, 0, 200.0f, 200.0f)] autorelease];
imageView2.imageUrl = @"http://www.desktopwallpaperhd.com/wallpapers/3/4501.jpg";
imageView2.defaultImage = [UIImage imageNamed:@"no-image.png"];
imageView2.corners = ZSRoundCornerTopLeft | ZSRoundCornerBottomLeft | ZSRoundCornerTopRight;
imageView2.cornerRadius = 10;
[self.view addSubview:imageView2];

If you want to give only some of the edges a border:

ZSImageView *imageView3 = [[[ZSImageView alloc] initWithFrame:CGRectMake(140, 300, 100.0f, 100.0f)] autorelease];
imageView3.imageUrl = @"http://www.taramtamtam.com/wallpapers/Sport/M/Mountain_biking/images/Mountain_biking_3.jpg";
imageView3.defaultImage = [UIImage imageNamed:@"no-image.png"];
imageView3.contentMode = UIViewContentModeScaleAspectFill;
imageView3.borders = ZSBorderRight | ZSBorderLeft | ZSBorderTop;
imageView3.borderWidth = 3.0;
imageView3.borderColor = [UIColor redColor];
imageView3.clipsToBounds = YES;
[self.view addSubview:imageView3];

Round Edges

There are five options you can use to round the edges of your ZSImageView. ZSRoundCornerTopLeft, ZSRoundCornerTopRight, ZSRoundCornerBottomLeft, ZSRoundCornerBottomRight, ZSRoundCornerAll. These can be combined to round a few edges or you can use ZSRoundCornerAll to round all of the edges. ZSRoundCornerNone is also available to reset the corners to none when reusing a ZSImageView, such as when using it in a UITableViewCell.

Borders

The great thing about using ZSImageView is that you can choose to only add a few borders if you would like. There are five options for this, ZSBorderTop, ZSBorderRight, ZSBorderBottom, ZSBorderLeft, and ZSBorderAll. There is also ZSBorderNone if you need to reset them when using cell reuse. There are defaults for borderWidth and borderColor but obviously you can set those as well.

How to use in your App

ZSImageView requires the QuartzCore.framework. Once you have that added you need to copy ZSImageView.h, ZSImageView.m, ZSLineView.h and ZSLineView.m as well as JMImageCache.h and JMImageCache.m to your project. Then #import the ZSImageView.h header file where you need it and start using it.

Notes

ZSImageView uses JMImageCache to load and cache the remote image.

zsimageview's People

Contributors

nnhubbard avatar

Stargazers

MohsinAli avatar

Watchers

MohsinAli avatar  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.