TKImageView
1.0.0
An easy way to crop an image.
| 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 | 是否需要顯示每條邊中間的線,這條中間線支持拖動手勢。 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 | 是否顯示裁剪框內的交叉線。 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 line width of the corner. |
| cropAreaCornerWidth | CGFloat | 設置裁剪邊框四個角的寬度,這裡指角的橫邊的長度。 The width of the corner area, indicate the length of the horizontal line of the corner. |
| cropAreaCornerHeight | CGFloat | 設置裁剪邊框四個角的高度,這裡指角的豎邊的長度。 The height of the corner area, indicate the length of the vertical line of the corner. |
| minspace | CGFloat | 相鄰角之間的最小距離。 The minimum distance between the corners. |
| 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. |
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!