A simple UIImageView category which can set border radius, shadow, circle and rotation for image view.
A simple UIImageView category with some extension functions.
Installing UIImageView+Extension by CocoaPods.
pod 'UIImageView+Extension', '~> 0.2'
UIImageView+Extension.h
and UIImageView+Extension.m
to your project.#import "UIImageView+Extension.h"
where you want to use the control.#import "UIImageView+Extension.h"
to your .h
or .m
file.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.
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;
You can rotate a image view infinitely by the method startRotate
, 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];
Setting blur is supported in Interface Builder. You can set blur style including
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;
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;
A demo project contained in this repository shows how to use UIImageView+Extension from a storyboard.
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
version 0.2.6
version 0.2.5.1
version 0.2.5
version 0.2.4
version 0.2.3
version 0.2.2
version 0.2.1
version 0.2.0
version 0.1.0
UIImageView+Extension is licensed under the terms of the MIT License. Please see the LICENSE file for full details.