views:

708

answers:

2

Does anyone know of a way to implement the zoom loupe functionality of a UITextField on the iphone in a UIImage view?

Part of the app I'm building allows a user to draw a line on a UIImage, a process that might involve precision positioning of the points. In order to help the user, I want to provide the zoom loupe as seen when positioning the cursor in a UITextField. Does anyone have any idea as to how to do this? Any pointers to relevant docs?

Cheers!

A: 

I do not know of any relevant docs.

What I would do when implement something like this is. Show a UIImage representation of your view over the view. Then clip the overlay UIImage to just the portion of the view you want to enlarge. You can enlarge the portion by using CGAffineTransformScale.

You can draw a existing view to a UIImage by using CALayer's renderInContext: method.

    UIGraphicsBeginImageContext(self.view.frame.size);

    CGContextRef context = UIGraphicsGetCurrentContext();
    [self.view.layer renderInContext:context];

    UIImage *imageRepresentation = UIGraphicsGetImageFromCurrentImageContext();
klaaspieter
+3  A: 

This tutorial is well written and includes sample code:

http://www.craftymind.com/2009/02/10/creating-the-loupe-or-magnifying-glass-effect-on-the-iphone/

You need to comment out the line that imports CustomView.h and then it compiles and runs fine.

Stephen Petschulat