Commit 1b528d38 authored by ZCJ's avatar ZCJ

no message

parent d54c84a5
//
// ImageCopperView.h
// PerfectImageCropper
//
// Created by Jin Huang on 11/22/12.
//
//
#import <UIKit/UIKit.h>
@protocol ImageCropperDelegate;
@interface ImageCropperView : UIImageView {
UIImageView *imageView;
}
@property (nonatomic, retain) UIImage *image;
@property (nonatomic, retain) UIImage *croppedImage;
@property (nonatomic, assign) id <ImageCropperDelegate> delegate;
- (void)setup;
- (void)finishCropping;
- (void)reset;
@end
@protocol ImageCropperDelegate <NSObject>
- (void)imageCropper:(ImageCropperView *)cropper didFinishCroppingWithImage:(UIImage *)image;
@end
\ No newline at end of file
//
// ImageCopperView.m
// PerfectImageCropper
//
// Created by Jin Huang on 11/22/12.
//
//
#import "ImageCropperView.h"
#import <QuartzCore/QuartzCore.h>
#include <math.h>
#import "UIImage+Rotation.h"
@interface ImageCropperView()
{
@private
CGSize _originalImageViewSize;
}
@property (nonatomic, retain) UIImageView *imageView;
@end
@implementation ImageCropperView
@synthesize imageView, image = _image, delegate, croppedImage;
- (void)setup
{
self.clipsToBounds = YES;
self.backgroundColor = [UIColor clearColor];
self.userInteractionEnabled = YES;
UIRotationGestureRecognizer *rotateGes = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotateImage:)];
[self addGestureRecognizer:rotateGes];
UIPinchGestureRecognizer *scaleGes = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(scaleImage:)];
[self addGestureRecognizer:scaleGes];
UIPanGestureRecognizer *moveGes = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(moveImage:)];
[moveGes setMinimumNumberOfTouches:1];
[moveGes setMaximumNumberOfTouches:1];
[self addGestureRecognizer:moveGes];
}
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
[self setup];
}
return self;
}
float _lastTransX = 0.0, _lastTransY = 0.0;
- (void)moveImage:(UIPanGestureRecognizer *)sender
{
CGPoint translatedPoint = [sender translationInView:self];
if([sender state] == UIGestureRecognizerStateBegan) {
_lastTransX = 0.0;
_lastTransY = 0.0;
}
CGAffineTransform trans = CGAffineTransformMakeTranslation(translatedPoint.x - _lastTransX, translatedPoint.y - _lastTransY);
CGAffineTransform newTransform = CGAffineTransformConcat(self.transform, trans);
_lastTransX = translatedPoint.x;
_lastTransY = translatedPoint.y;
self.transform = newTransform;
}
float _lastScale = 1.0;
- (void)scaleImage:(UIPinchGestureRecognizer *)sender
{
if([sender state] == UIGestureRecognizerStateBegan) {
_lastScale = 1.0;
return;
}
CGFloat scale = [sender scale]/_lastScale;
CGAffineTransform currentTransform = self.transform;
CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, scale, scale);
[self setTransform:newTransform];
_lastScale = [sender scale];
}
float _lastRotation = 0.0;
- (void)rotateImage:(UIRotationGestureRecognizer *)sender
{
if([sender state] == UIGestureRecognizerStateEnded) {
_lastRotation = 0.0;
return;
}
CGFloat rotation = -_lastRotation + [sender rotation];
CGAffineTransform currentTransform = self.transform;
CGAffineTransform newTransform = CGAffineTransformRotate(currentTransform,rotation);
[self setTransform:newTransform];
_lastRotation = [sender rotation];
}
@end
//
// UIImage+Rotation.h
// PerfectImageCropper
//
// Created by Jin Huang on 5/29/13.
// Copyright (c) 2013 Jin Huang. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface UIImage (Rotation)
- (UIImage *)imageRotatedByRadians:(CGFloat)radians;
- (UIImage *)imageRotatedByDegrees:(CGFloat)degrees;
@end
//
// UIImage+Rotation.m
// PerfectImageCropper
//
// Created by Jin Huang on 5/29/13.
// Copyright (c) 2013 Jin Huang. All rights reserved.
//
#import "UIImage+Rotation.h"
CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;};
CGFloat RadiansToDegrees(CGFloat radians) {return radians * 180/M_PI;};
@implementation UIImage (Rotation)
- (UIImage *)imageRotatedByRadians:(CGFloat)radians
{
return [self imageRotatedByDegrees:RadiansToDegrees(radians)];
}
- (UIImage *)imageRotatedByDegrees:(CGFloat)degrees
{
UIView *rotatedViewBox = [[UIView alloc] initWithFrame:CGRectMake(0,0,self.size.width, self.size.height)];
CGAffineTransform t = CGAffineTransformMakeRotation(DegreesToRadians(degrees));
rotatedViewBox.transform = t;
CGSize rotatedSize = rotatedViewBox.frame.size;
UIGraphicsBeginImageContext(rotatedSize);
CGContextRef bitmap = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(bitmap, rotatedSize.width/2, rotatedSize.height/2);
CGContextRotateCTM(bitmap, DegreesToRadians(degrees));
CGContextScaleCTM(bitmap, 1.0, -1.0);
CGContextDrawImage(bitmap, CGRectMake(-self.size.width / 2, -self.size.height / 2, self.size.width, self.size.height), [self CGImage]);
UIImage *resImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return resImage;
}
@end;
...@@ -14,8 +14,8 @@ ...@@ -14,8 +14,8 @@
04A14A251CE0FC3A00DAD5F3 /* LeftSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A14A241CE0FC3A00DAD5F3 /* LeftSubView.m */; }; 04A14A251CE0FC3A00DAD5F3 /* LeftSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A14A241CE0FC3A00DAD5F3 /* LeftSubView.m */; };
04A14A281CE0FC5600DAD5F3 /* RightSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A14A271CE0FC5600DAD5F3 /* RightSubView.m */; }; 04A14A281CE0FC5600DAD5F3 /* RightSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A14A271CE0FC5600DAD5F3 /* RightSubView.m */; };
04A14A2B1CE0FC7F00DAD5F3 /* FootSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A14A2A1CE0FC7F00DAD5F3 /* FootSubView.m */; }; 04A14A2B1CE0FC7F00DAD5F3 /* FootSubView.m in Sources */ = {isa = PBXBuildFile; fileRef = 04A14A2A1CE0FC7F00DAD5F3 /* FootSubView.m */; };
060D39751CE456460082AECD /* ImageCropperView.m in Sources */ = {isa = PBXBuildFile; fileRef = 060D39721CE456460082AECD /* ImageCropperView.m */; }; 060D397C1CE45CFE0082AECD /* ImageCropperView.m in Sources */ = {isa = PBXBuildFile; fileRef = 060D39791CE45CFE0082AECD /* ImageCropperView.m */; };
060D39761CE456460082AECD /* UIImage+Rotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 060D39741CE456460082AECD /* UIImage+Rotation.m */; }; 060D397D1CE45CFE0082AECD /* UIImage+Rotation.m in Sources */ = {isa = PBXBuildFile; fileRef = 060D397B1CE45CFE0082AECD /* UIImage+Rotation.m */; };
2906B5D71CD89246000849B4 /* ClientDetailsTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2906B5D61CD89246000849B4 /* ClientDetailsTableViewCell.m */; }; 2906B5D71CD89246000849B4 /* ClientDetailsTableViewCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 2906B5D61CD89246000849B4 /* ClientDetailsTableViewCell.m */; };
2928F7E71CD087FE0036D761 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2928F7E61CD087FE0036D761 /* BaseViewController.m */; }; 2928F7E71CD087FE0036D761 /* BaseViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2928F7E61CD087FE0036D761 /* BaseViewController.m */; };
2928F8321CD09E320036D761 /* Toolview.m in Sources */ = {isa = PBXBuildFile; fileRef = 2928F8311CD09E320036D761 /* Toolview.m */; }; 2928F8321CD09E320036D761 /* Toolview.m in Sources */ = {isa = PBXBuildFile; fileRef = 2928F8311CD09E320036D761 /* Toolview.m */; };
...@@ -116,10 +116,10 @@ ...@@ -116,10 +116,10 @@
04A14A271CE0FC5600DAD5F3 /* RightSubView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RightSubView.m; sourceTree = "<group>"; }; 04A14A271CE0FC5600DAD5F3 /* RightSubView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RightSubView.m; sourceTree = "<group>"; };
04A14A291CE0FC7F00DAD5F3 /* FootSubView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FootSubView.h; sourceTree = "<group>"; }; 04A14A291CE0FC7F00DAD5F3 /* FootSubView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FootSubView.h; sourceTree = "<group>"; };
04A14A2A1CE0FC7F00DAD5F3 /* FootSubView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FootSubView.m; sourceTree = "<group>"; }; 04A14A2A1CE0FC7F00DAD5F3 /* FootSubView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FootSubView.m; sourceTree = "<group>"; };
060D39711CE456460082AECD /* ImageCropperView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageCropperView.h; sourceTree = "<group>"; }; 060D39781CE45CFE0082AECD /* ImageCropperView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ImageCropperView.h; sourceTree = "<group>"; };
060D39721CE456460082AECD /* ImageCropperView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageCropperView.m; sourceTree = "<group>"; }; 060D39791CE45CFE0082AECD /* ImageCropperView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ImageCropperView.m; sourceTree = "<group>"; };
060D39731CE456460082AECD /* UIImage+Rotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Rotation.h"; sourceTree = "<group>"; }; 060D397A1CE45CFE0082AECD /* UIImage+Rotation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Rotation.h"; sourceTree = "<group>"; };
060D39741CE456460082AECD /* UIImage+Rotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Rotation.m"; sourceTree = "<group>"; }; 060D397B1CE45CFE0082AECD /* UIImage+Rotation.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Rotation.m"; sourceTree = "<group>"; };
18E6D8479D48A4650167EAF2 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; }; 18E6D8479D48A4650167EAF2 /* libPods.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libPods.a; sourceTree = BUILT_PRODUCTS_DIR; };
2906B5D51CD89246000849B4 /* ClientDetailsTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientDetailsTableViewCell.h; sourceTree = "<group>"; }; 2906B5D51CD89246000849B4 /* ClientDetailsTableViewCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClientDetailsTableViewCell.h; sourceTree = "<group>"; };
2906B5D61CD89246000849B4 /* ClientDetailsTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClientDetailsTableViewCell.m; sourceTree = "<group>"; }; 2906B5D61CD89246000849B4 /* ClientDetailsTableViewCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ClientDetailsTableViewCell.m; sourceTree = "<group>"; };
...@@ -348,16 +348,15 @@ ...@@ -348,16 +348,15 @@
name = views; name = views;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
060D39701CE456460082AECD /* tools */ = { 060D39771CE45CFE0082AECD /* tools */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
060D39711CE456460082AECD /* ImageCropperView.h */, 060D39781CE45CFE0082AECD /* ImageCropperView.h */,
060D39721CE456460082AECD /* ImageCropperView.m */, 060D39791CE45CFE0082AECD /* ImageCropperView.m */,
060D39731CE456460082AECD /* UIImage+Rotation.h */, 060D397A1CE45CFE0082AECD /* UIImage+Rotation.h */,
060D39741CE456460082AECD /* UIImage+Rotation.m */, 060D397B1CE45CFE0082AECD /* UIImage+Rotation.m */,
); );
name = tools; path = tools;
path = ../../../Desktop/tools;
sourceTree = "<group>"; sourceTree = "<group>";
}; };
2906B5D31CD8920F000849B4 /* Controller */ = { 2906B5D31CD8920F000849B4 /* Controller */ = {
...@@ -755,7 +754,7 @@ ...@@ -755,7 +754,7 @@
29BB27691CD9DDF3009A0813 /* FollowHeartVC */ = { 29BB27691CD9DDF3009A0813 /* FollowHeartVC */ = {
isa = PBXGroup; isa = PBXGroup;
children = ( children = (
060D39701CE456460082AECD /* tools */, 060D39771CE45CFE0082AECD /* tools */,
0470D60E1CE292EF00647F0F /* subView */, 0470D60E1CE292EF00647F0F /* subView */,
04A14A221CE0FB8400DAD5F3 /* views */, 04A14A221CE0FB8400DAD5F3 /* views */,
29BB276A1CD9DE74009A0813 /* FollowHeartViewController.h */, 29BB276A1CD9DE74009A0813 /* FollowHeartViewController.h */,
...@@ -1110,13 +1109,13 @@ ...@@ -1110,13 +1109,13 @@
04A14A281CE0FC5600DAD5F3 /* RightSubView.m in Sources */, 04A14A281CE0FC5600DAD5F3 /* RightSubView.m in Sources */,
29EC331F1CE02AFA005F0C13 /* PopoverViewController.m in Sources */, 29EC331F1CE02AFA005F0C13 /* PopoverViewController.m in Sources */,
299C7F5A1CE21FA800E7D7CB /* AddressViewController.m in Sources */, 299C7F5A1CE21FA800E7D7CB /* AddressViewController.m in Sources */,
060D39761CE456460082AECD /* UIImage+Rotation.m in Sources */,
29BB276C1CD9DE74009A0813 /* FollowHeartViewController.m in Sources */, 29BB276C1CD9DE74009A0813 /* FollowHeartViewController.m in Sources */,
2928F8381CD09E730036D761 /* CustomButton.m in Sources */, 2928F8381CD09E730036D761 /* CustomButton.m in Sources */,
0470D6111CE2936000647F0F /* SeceneLibraryView.m in Sources */, 0470D6111CE2936000647F0F /* SeceneLibraryView.m in Sources */,
2998763F1CD9985B00C90D0A /* AttachmentInformationTableViewCell.m in Sources */, 2998763F1CD9985B00C90D0A /* AttachmentInformationTableViewCell.m in Sources */,
293393551CD3379E000D997B /* ShoppingTableViewCell.m in Sources */, 293393551CD3379E000D997B /* ShoppingTableViewCell.m in Sources */,
29EAAE951CDC414C00C4DBA2 /* SeceneLibraryCollectionViewCell.m in Sources */, 29EAAE951CDC414C00C4DBA2 /* SeceneLibraryCollectionViewCell.m in Sources */,
060D397C1CE45CFE0082AECD /* ImageCropperView.m in Sources */,
2949BAC21CD3055A0049385A /* MMExampleDrawerVisualStateManager.m in Sources */, 2949BAC21CD3055A0049385A /* MMExampleDrawerVisualStateManager.m in Sources */,
29A938221CDADE4700F21E54 /* ProductDetailsTableViewCell.m in Sources */, 29A938221CDADE4700F21E54 /* ProductDetailsTableViewCell.m in Sources */,
2992493D1CDB3E8900786B1E /* GenerateOrdersModifyTableViewCell.m in Sources */, 2992493D1CDB3E8900786B1E /* GenerateOrdersModifyTableViewCell.m in Sources */,
...@@ -1152,12 +1151,12 @@ ...@@ -1152,12 +1151,12 @@
29EC331A1CE023D5005F0C13 /* ChangePasswordViewController.m in Sources */, 29EC331A1CE023D5005F0C13 /* ChangePasswordViewController.m in Sources */,
2962D07D1CD1E4490058829D /* NSArray+Objectwithindex.m in Sources */, 2962D07D1CD1E4490058829D /* NSArray+Objectwithindex.m in Sources */,
04A14A251CE0FC3A00DAD5F3 /* LeftSubView.m in Sources */, 04A14A251CE0FC3A00DAD5F3 /* LeftSubView.m in Sources */,
060D39751CE456460082AECD /* ImageCropperView.m in Sources */,
299876391CD9981800C90D0A /* GoodsInformationTableViewCell.m in Sources */, 299876391CD9981800C90D0A /* GoodsInformationTableViewCell.m in Sources */,
2949BABD1CD2EFA00049385A /* InformationTableViewCell.m in Sources */, 2949BABD1CD2EFA00049385A /* InformationTableViewCell.m in Sources */,
29706DB21CD082990003C412 /* Lighting.xcdatamodeld in Sources */, 29706DB21CD082990003C412 /* Lighting.xcdatamodeld in Sources */,
29834EB91CDF1FB3001A484F /* screeningFirstView.m in Sources */, 29834EB91CDF1FB3001A484F /* screeningFirstView.m in Sources */,
299249401CDB4D1D00786B1E /* AddaddressViewController.m in Sources */, 299249401CDB4D1D00786B1E /* AddaddressViewController.m in Sources */,
060D397D1CE45CFE0082AECD /* UIImage+Rotation.m in Sources */,
299249371CDB3C6500786B1E /* GenerateOrdersViewController.m in Sources */, 299249371CDB3C6500786B1E /* GenerateOrdersViewController.m in Sources */,
2992493A1CDB3E4500786B1E /* GenerateOrdersTableViewCell.m in Sources */, 2992493A1CDB3E4500786B1E /* GenerateOrdersTableViewCell.m in Sources */,
2962D0811CD1E6010058829D /* UIView+Frame.m in Sources */, 2962D0811CD1E6010058829D /* UIView+Frame.m in Sources */,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment