Skip to content

Instantly share code, notes, and snippets.

@pita5
Created January 6, 2012 22:35
Show Gist options
  • Save pita5/1572743 to your computer and use it in GitHub Desktop.
Save pita5/1572743 to your computer and use it in GitHub Desktop.
@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