“掩饰"动画?iPhone SDK

quot;Maskingquot; an animation? iPhone SDK(“掩饰动画?iPhone SDK)
本文介绍了“掩饰"动画?iPhone SDK的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在研究如何在 iPhone 上屏蔽图像.我遇到了这个解决方案

I have been looking into ways of masking images on the iPhone. I came across this solution

http://iosdevelopertips.com/cocoa/how-to-mask-an-image.html

这对静止图像非常有用.我想要做的是在 UIImageView 中屏蔽动画.根据我的阅读,我认为这是不可能的,同时还能实现不错的帧速率.

which works great for still images. What I want to do is mask an animation in a UIImageView. From what I have read I don't think this is possible whilst also achieving a decent frame rate.

这让我问以下是否可能,我可以剪辑" UIImageView 内的图像吗?即不将 UIImageView 的大小重新调整为图像的大小,以便将某些部分切掉?

This leads me to ask whether the following is possible, could I "clip" the images inside the UIImageView? ie not re-size the UIImageView to the size of the images so some parts are chopped off?

推荐答案

我没有尝试过这个性能,但你可以使用核心动画层作为蒙版.您可以定义要在 CAShapeLayer 中使用的路径并填充形状.然后指定 UIImageView 图层的图层蒙版.比如:

I haven't tried this for performance, but you can use a Core Animation layer as a mask. You can define a path to use in a CAShapeLayer and fill the shape. Then specify the layer mask of your UIImageView's layer. Something like:

CGMutablePathRef path = CGPathCreateMutable();
// build the path by adding points
// ...

CAShapeLayer *shapeLayer = [[CAShapeLayer alloc] init];
[shapeLayer setPath:path];
[shapeLayer setFillColor:[[UIColor blackColor] CGColor]];
// Set shape layer bounds and position
// ...

// Set the mask for the image view's layer
[[imageView layer] setMask:shapeLayer];

请记住,这实际上并不是像您引用的链接那样创建新图像.这只是创建了一个遮罩,用于显示在您的图像视图之上——这可能不是您想要的.

Keep in mind that this isn't actually creating a new image as the link you reference does. This just creates a mask for display over top of your image view--which may not be what you want.

这篇关于“掩饰"动画?iPhone SDK的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Pushing UIViewController above UITabBar(将UIView控制器推送到UITabBar上方)
java.lang.IllegalStateException: SimpleTypeImpl should not be created for error type(异常:不应为错误类型创建SimpleTypeImpl)
Android IllegalArgumentException: The tag for fragment_XXX is invalid. Received: layout-sw600dp/fragment_XXX_0(Android IlLegalArgumentException:Fragment_XXX的标签无效。收到:Layout-sw600dp/Fragment_XXX_0)
iOS convert audio sample rate from 16 kHz to 8 kHz(IOS将音频采样率从16 kHz转换为8 kHz)
Enforcing an audio sampling rate in iOS(在iOS中强制音频采样率)
HTTPS request using volley(使用 volley 的 HTTPS 请求)