Git Product home page Git Product logo

tkimageview's Introduction

TKImageView

An easy way to crop an image.
##Features

  • Both iPhone/iPad available
  • Support pinch gesture to zoom
  • Support pan gesture to move&resize
  • Support cutomize line width and color
  • Support cross line and middle line

##System requirements

  • iOS 7.0 or higher

##Samples ##Properties

name type description
toCropImage UIImage the image you want to crop.
needScaleCrop BOOL determines whether you need to scale crop with pinch gesture or not.
showMidLines BOOL thow the lines in the middle of each border, which can receive pan gesture to resize the crop area when the aspect ratio is ZERO.
showCrossLines BOOL show the cross lines in the crop area.
cropAspectRatio CGFloat The aspect retio you want to crop the image, equals to WIDTH / HEIGHT.
cropAreaBorderLineColor UIColor the color of border lines.
cropAreaBorderLineWidth CGFloat the width of border lines.
cropAreaCornerLineColor UIColor the line color of the corner.
cropAreaCornerLineWidth CGFloat the width of the corner area, not the line width in corner.
cropAreaCornerWidth CGFloat the line width of the corner.
cropAreaCornerHeight CGFloat the height of the corner area.
minspace CGFloat the minimum distance between the corners of one border.
cropAreaCrossLineWidth CGFloat the width of cross lines.
cropAreaCrossLineColor UIColor the color of cross lines.
cropAreaMidLineWidth CGFloat the width of middle lines.
cropAreaMidLineHeight CGFloat the height of middle lines.
cropAreaMidLineColor UIColor the color of middle lines.
maskColor UIColor the color of the mask view which is always transparent black.
cornerBorderInImage BOOL whether the corner border inside the image or not.

cornerBorderInImage = YES

cornerBorderInImage = NO

Usage

TKImageView support both initWithFrame and initWithCoder to initialize. The properties should be set or keep default after the initialize.Once one property has been set, you should not change it any more.

@property (weak, nonatomic) IBOutlet TKImageView *tkImageView;
- (void)viewDidLoad {   
	_tkImageView.toCropImage = [UIImage imageNamed: @"test.jpg"];
	_tkImageView.showMidLines = YES;
	_tkImageView.needScaleCrop = YES;
	_tkImageView.showCrossLines = YES;
	_tkImageView.cornerBorderInImage = NO;
	_tkImageView.cropAreaCornerWidth = 44;
	_tkImageView.cropAreaCornerHeight = 44;
	_tkImageView.minSpace = 30;
	_tkImageView.cropAreaCornerLineColor = [UIColor whiteColor];
	_tkImageView.cropAreaBorderLineColor = [UIColor whiteColor];
	_tkImageView.cropAreaCornerLineWidth = 8;
	_tkImageView.cropAreaBorderLineWidth = 6;
	_tkImageView.cropAreaMidLineWidth = 30;
	_tkImageView.cropAreaMidLineHeight = 8;
	_tkImageView.cropAreaMidLineColor = [UIColor whiteColor];
	_tkImageView.cropAreaCrossLineColor = [UIColor whiteColor];
	_tkImageView.cropAreaCrossLineWidth = 6;    
}

Function

You can get the cropped image by this function.

- (UIImage *)currentCroppedImage;

Bug&Feature Report

If you find any bugs in my code or you think it is useful to add some features in this tool, please write a issue or mail to me [email protected], thanks a lot!

tkimageview's People

Contributors

3tinkers avatar

Watchers

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