Created
January 6, 2012 22:35
-
-
Save pita5/1572743 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@implementation EGOLoupeView | |
+ (CFTimeInterval)fadeDuration | |
{ | |
return 0.0; | |
} | |
+ (Class)layerClass | |
{ | |
return [CATiledLayer class]; | |
} | |
- (id)init | |
{ | |
if ((self = [super initWithFrame:CGRectMake(0.0f, 0.0f, 127.0f, 127.0f)])) | |
{ | |
self.backgroundColor = [UIColor clearColor]; | |
} | |
return self; | |
} | |
- (void)drawRect:(CGRect)rect | |
{ | |
CGContextRef ctx = UIGraphicsGetCurrentContext(); | |
[[UIImage imageNamed:@"loupe-lo.png"] drawInRect:rect]; | |
if ((_contentImage!=nil)) { | |
CGContextSaveGState(ctx); | |
CGContextClipToMask(ctx, rect, [UIImage imageNamed:@"loupe-mask.png"].CGImage); | |
CGContextDrawImage(ctx, rect, _contentImage.CGImage); | |
// [_contentImage drawInRect:rect]; | |
CGContextRestoreGState(ctx); | |
} | |
[[UIImage imageNamed:@"loupe-hi.png"] drawInRect:rect]; | |
} | |
- (void)setContentImage:(UIImage *)image | |
{ | |
@synchronized(self) | |
{ | |
[_contentImage release], _contentImage=nil; | |
_contentImage = [image retain]; | |
[self setNeedsDisplay]; | |
} | |
} | |
- (void)dealloc { | |
[_contentImage release], _contentImage=nil; | |
[super dealloc]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment