0

您好想知道是否有人知道如何在 iPhone 上为文本制作放大镜效果。网上有很多 JavaScript 示例说明如何对图像执行此操作,甚至还有一些是为文本设计的,但是这些示例都不能在移动设备上使用触摸和拖动。

我对 HTML 和 JavaScript 有点陌生,所以任何帮助都将不胜感激。(顺便说一下,我知道 iPhone 有一个内置的放大镜,但我需要它更大,放大更远)

干杯

4

1 回答 1

1

你可以看看这个你的想法,这个演示实现了效果 http://www.craftymind.com/creating-the-loupe-or-magnifying-glass-effect-on-the-iphone/

主要代码是这样的

- (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];

}

于 2014-12-04T06:32:09.697 回答