TKImageView
1.0.0
An easy way to crop an image.
| name | type | Description |
|---|---|---|
| toCropImage | UIImage | Pictures to be cropped. The image you want to crop. |
| needScaleCrop | BOOL | Whether to scale and crop. Determines whether you need to scale crop with pinch gesture or not. |
| showMidLines | BOOL | Whether to display the line in the middle of each edge, this middle line supports drag gestures. Show 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 | Whether to display cross lines in the crop box. Show the cross lines in the crop area. |
| cropAspectRatio | CGFloat | Sets the aspect ratio of the crop box. The aspect retio you want to crop the image, equals to WIDTH / HEIGHT. |
| cropAreaBorderLineColor | UIColor | Sets the color of the crop border. The color of border lines. |
| cropAreaBorderLineWidth | CGFloat | Sets the line width of the crop border. The width of border lines. |
| cropAreaCornerLineColor | UIColor | Set the color of the four corners of the crop border. The line color of the corner. |
| cropAreaCornerLineWidth | CGFloat | Set the line width of the four corners of the crop border. The line width of the corner. |
| cropAreaCornerWidth | CGFloat | Set the width of the four corners of the crop border, which refers to the length of the horizontal edge of the corner. The width of the corner area, indicates the length of the horizontal line of the corner. |
| cropAreaCornerHeight | CGFloat | Set the height of the four corners of the crop border, which refers to the length of the vertical edge of the corner. The height of the corner area, indicates the length of the vertical line of the corner. |
| Minspace | CGFloat | Minimum distance between adjacent angles. The minimum distance between the corners. |
| cropAreaCrossLineWidth | CGFloat | The width of the crossed lines in the crop box. The width of cross lines. |
| cropAreaCrossLineColor | UIColor | Crop the color of the crossed lines in the box. The color of cross lines. |
| cropAreaMidLineWidth | CGFloat | Crop the length of the middle line of each edge of the border. The width of middle lines. |
| cropAreaMidLineHeight | CGFloat | Crop the line width of the middle line of each edge of the border. The height of middle lines. |
| cropAreaMidLineColor | UIColor | Crop the color of the middle line of each edge of the border. The color of middle lines. |
| maskColor | UIColor | Mask color for cropped area. The color of the mask view which is always transparent black. |
| cornerBorderInImage | BOOL | Whether the four corners of the crop border can be beyond the image display. Whether the corner border inside the image or not. |
TKImageView supports both initWithFrame and initWithCoder to initialize.You can customize your TKImageView instance with the properties to match your design.
@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;
}
You can get the cropped image by this function.
- (UIImage *)currentCroppedImage;
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!