Roksalt
Roksalt

Reputation: 481

Text Magnifying glass for iOS device

Hi was wondering if anyone knows how to make a magnifying glass effect for text on the iPhone. There are so many JavaScript examples online for how to do this for images and there are even a few that are designed for text, however none of these work with touch and drag on a mobile device.

Im a bit of a noobie with HTML and JavaScript so any help would be appreciated. (by the way I know the iPhone has a built in magnify but I need it to be a lot bigger and zoom farther)

Cheers

Upvotes: 0

Views: 708

Answers (1)

NSKevin
NSKevin

Reputation: 574

you can check out this for your idea, this demo implement the effect http://www.craftymind.com/creating-the-loupe-or-magnifying-glass-effect-on-the-iphone/

the main code is like this

- (void)drawRect:(CGRect)rect {
    // here we're just doing some transforms on the view we're magnifying,
    // and rendering that view directly into this view,
    // rather than the previous method of copying an image.
    CGContextRef context = UIGraphicsGetCurrentContext();
    CGContextTranslateCTM(context,1*(self.frame.size.width*0.5),1*(self.frame.size.height*0.5));
    CGContextScaleCTM(context, 1.5, 1.5);
    CGContextTranslateCTM(context,-1*(touchPoint.x),-1*(touchPoint.y));
    [self.viewToMagnify.layer renderInContext:context];

}

Upvotes: 1

Related Questions