Marty
Marty

Reputation: 6174

How to enlarge/blow up/zoom a certain part of a UIImageView on iPhone?

I have a magnifying glass as a UIImageView subview of a UIView. I want to enlarge the part of the UIView that the magnifying glass is on. I can't figure out how to enlarge a certain part of the view. I assume it has to be a rectangle and not a circle? How could I blow it up? I don't have much CA experience so a shove in the right direction would help.

Upvotes: 0

Views: 1717

Answers (2)

Pat
Pat

Reputation: 2529

I am about to do the same thing. Here is an example of how to capture a view in an image. You can then zoom in the image in the bubble:

UIGraphicsBeginImageContext(view.bounds.size);
[view.layer renderInContext:UIGraphicsGetCurrentContext()];
self.image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();

Upvotes: 0

TigerCoding
TigerCoding

Reputation: 8720

If you want to zoom a static image, then you can do this:

Make the magnifyingView (UIView) have a sub-view that's a UIImageView. The UIImageView has the same image that's being magnified, but much larger. Have the magnifyingView clip to bounds set. Then, as the UIView is moved by the user dragging/touching, the subview is moved in relation to that to create a magnify effect.

I'd have to look up how to magnify dynamic content myself.

Upvotes: 1

Related Questions