Skip to content

Commit

Permalink
Added scaleAtTouchPoint to ACMagnifyingGlass to magnify portion of th…
Browse files Browse the repository at this point in the history
…e view at touch or under magnifier to be scaled up
  • Loading branch information
Arnaud Coomans committed Apr 14, 2012
1 parent d73cbfa commit 69f0f88
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions MagnifyingGlass/ACMagnifyingGlass.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
@property (nonatomic, assign) CGPoint touchPoint;
@property (nonatomic, assign) CGPoint touchPointOffset;
@property (nonatomic, assign) CGFloat scale;
@property (nonatomic, assign) BOOL scaleAtTouchPoint;

@end
5 changes: 3 additions & 2 deletions MagnifyingGlass/ACMagnifyingGlass.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ @interface ACMagnifyingGlass ()

@implementation ACMagnifyingGlass

@synthesize viewToMagnify, touchPoint, touchPointOffset, scale;
@synthesize viewToMagnify, touchPoint, touchPointOffset, scale, scaleAtTouchPoint;

- (id)init {
self = [self initWithFrame:CGRectMake(0, 0, kACMagnifyingGlassDefaultRadius*2, kACMagnifyingGlassDefaultRadius*2)];
Expand All @@ -34,6 +34,7 @@ - (id)initWithFrame:(CGRect)frame {
self.touchPointOffset = CGPointMake(0, kACMagnifyingGlassDefaultOffset);
self.scale = kACMagnifyingGlassDefaultScale;
self.viewToMagnify = nil;
self.scaleAtTouchPoint = YES;
}
return self;
}
Expand All @@ -52,7 +53,7 @@ - (void)drawRect:(CGRect)rect {
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextTranslateCTM(context, self.frame.size.width/2, self.frame.size.height/2 );
CGContextScaleCTM(context, scale, scale);
CGContextTranslateCTM(context, -touchPoint.x, -touchPoint.y);
CGContextTranslateCTM(context, -touchPoint.x, -touchPoint.y + (self.scaleAtTouchPoint? 0 : self.bounds.size.height/2));
[self.viewToMagnify.layer renderInContext:context];
}

Expand Down
1 change: 1 addition & 0 deletions MagnifyingGlassDemo/ACViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ - (void)viewDidLoad {
// loupe
ACLoupe *loupe = [[ACLoupe alloc] init];
self.magnifyingView.magnifyingGlass = loupe;
loupe.scaleAtTouchPoint = NO;


}
Expand Down

0 comments on commit 69f0f88

Please sign in to comment.