ios - UIView 图像中的缩放效果

标签 ios uiview uiimageview uigesturerecognizer uiviewanimation

Below is the image of human body

当用户将鼠标悬停在图像上时,点击某个 body 部位会显示该区域的放大图像。我想知道任何可能的第三方框架来解决可以帮助我实现此功能的此类功能或代码片段(例如使用哪些手势识别器)。

问题 2:我还必须在触摸发生和结束的位置添加一个动态的可点击标签(如您在图像中看到的手腕标签),这样我就可以将用户从该屏幕带到一个单独的 View 点击标签。如何做到这一点?

最佳答案

在您的 drawRect 方法中,遮住一个圆(使用包含放大镜“ mask ”的单色位图)并使用 2 倍比例变换在其中绘制主题 View 。然后在上面画一个放大镜图像,你就完成了。

- (void) drawRect: (CGRect) rect {
    CGContextRef    context = UIGraphicsGetCurrentContext();
    CGRect          bounds = self.bounds;
    CGImageRef      mask = [UIImage imageNamed: @"loupeMask"].CGImage;
    UIImage         *glass = [UIImage imageNamed: @"loupeImage"];

    CGContextSaveGState(context);
    CGContextClipToMask(context, bounds, mask);
    CGContextFillRect(context, bounds);
    CGContextScaleCTM(context, 2.0, 2.0);

    //draw your subject view here

    CGContextRestoreGState(context);

    [glass drawInRect: bounds];
}

检查 this完整示例的链接。

关于ios - UIView 图像中的缩放效果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20519055/

相关文章:

ios - 快速访问容器按钮

iphone - 如何从 xcode 中的 nib 文件创建 View ?

ios - 如何更改 UIImageView 中单个像素的图像

ios - 表格 View 单元格中的 Storyboard ImageView

iphone - 在 UIImageView 中同步后台作业

ios - <b> 标记在 UILabel 属性字符串中不起作用

ios - 将 UIView 显示为弧线

ios - subview 层变换和布局 subview

iphone - 使用上一篇文章的解决方案自定义分组 TableView 的背景/边框颜色

iphone - 如何在 tmx map 中提取折线点?