Git Product home page Git Product logo

uiimageview-extension's Introduction

UIImageView+Extension Supported Platforms Latest pod release Build Status License

A simple UIImageView category with some extension functions.

Features

  • Support Interface Builder.
  • Set border radius for image view.
  • Set shadow for image view.
  • Rotate image view.
  • Set image view to circle.

Installation

CocoaPods

Installing UIImageView+Extension by CocoaPods.

pod 'UIImageView+Extension', '~> 0.2'

Manual Way

  • Add UIImageView+Extension.h and UIImageView+Extension.m to your project.
  • #import "UIImageView+Extension.h" where you want to use the control.
  • These files require ARC.

Usage

  • If you just want to set features in Interface Builder, just do it in Interface Builder, you need not to do anything.

Interface Builder Guide

  • If you want to control your image view in your program, you should import the category header: #import "UIImageView+Extension.h" to your .h or .m file.

API Document

Corner Radius

Setting corner radius is supported in Interface Builder.

// Set corner radius.
_imageView.cornerRadius = 10;

The method setImageCornerRadius:(version 0.2.1 and before) is not recommended to use in this version now.

Shadow

Setting shadow is supported in Interface Builder.

You can also set them in your code. Shadow color and radius are necessary to create a shadow. Shadow will be shown after you set shadow color and radius.

// Change shadow color, offset and radius.
_imageView.shadowColor = [UIColor redColor];
_imageView.shadowRadius = 1.0;
_imageView.shadowXOffset = 1.0;
_imageView.shadowYOffset = 1.0;

Rotate

You can rotate a image view infinitely by the method startRotate:withClockwise:, the first parameter is rotation time per 1 round, the second parameter decides this rotation is clockwise or anticlockwise.

// Init a shadow with color, offset and raduis.
[_imageView startRotate:2 withClockwise:NO];

// Change shadow color, offset and radius.
[_imageView stopRotate];

Blur

Setting blur is supported in Interface Builder. You can set blur style including

  • extraLight (UIBlurEffectStyleExtraLight)
  • light (UIBlurEffectStyleLight)
  • dark (UIBlurEffectStyleDark)
  • regular (UIBlurEffectStyleRegular)
  • prominent (UIBlurEffectStyleProminent)

and blur alpha(0 < alpha <= 1) directly in the Interface Builder. The default style is regular.

// Change blur style, here use the enum UIBlurEffectStyle.
[_imageView changeBlurEffectStyle:UIBlurEffectStyleExtraLight];

// Change blur alpha.
_imageView.blurAlpha = 0.5;

Circle

Setting image view to circle is supported in Interface Builder. You must insure your image view is a square(width = height). We recommend you add Aspect Ratio constraint for your image view.

_imageView.circle = YES;
  • Tip: If you set corner radius and circle at same time, corner radius will be invalid.

Demo App

A demo project contained in this repository shows how to use UIImageView+Extension from a storyboard.

Demo App

Another demo app: I used this extension in my app Rate Assistant, you can download this app from App Store: https://itunes.apple.com/app/murate/id1139573801 to see this demo, it is an open source app, you can get the source code from https://github.com/MuShare/Rate-iOS

Change log

  • version 0.2.6

    • Set userInteractionEnabled in the shadow container to make image view clickale.
    • Give a tip when the image view has no parent view.
  • version 0.2.5.1

    • Fix some issues.
  • version 0.2.5

    • Fix the issue that UIImageView+Extension will affect the display of split line in UISegmentedControl.
  • version 0.2.4

    • Shadow container needs not init manually, so we removed setImageCornerRadius and setShadowWithColor method from interface.
    • Fix the issue that image view(circle attribute ON) is not cirle with auto layout.
  • version 0.2.3

    • Blur image view.
    • Fix the constraint bug for shadow. This version fixed the bug that position and size of a shadow will be wrong if image view has some constraint in the old version.
  • version 0.2.2

    • Set image view to circle.
    • Set corner radius by setter method directly.
  • version 0.2.1

    • Rotate image view infinitely.
  • version 0.2.0

    • Support Interface Builder.
    • Support changing shadow style.
  • version 0.1.0

    • Set corner radius and shadow for UIImageView.

License

UIImageView+Extension is licensed under the terms of the MIT License. Please see the LICENSE file for full details.

uiimageview-extension's People

Contributors

lm2343635 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

taroyuyu

uiimageview-extension's Issues

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.