quot;Maskingquot; an animation? 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的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:“掩饰"动画?iPhone SDK
基础教程推荐
- 当从同一个组件调用时,两个 IBAction 触发的顺序是什么? 2022-01-01
- android 应用程序已发布,但在 google play 中找不到 2022-01-01
- 如何在 iPhone 上显示来自 API 的 HTML 文本? 2022-01-01
- Android:对话框关闭而不调用关闭 2022-01-01
- 在 gmail 中为 ios 应用程序检索朋友的朋友 2022-01-01
- UIWebView 委托方法 shouldStartLoadWithRequest:在 WKWebView 中等效? 2022-01-01
- 如何在没有IB的情况下将2个按钮添加到右侧的UINavigationbar? 2022-01-01
- Kivy Buildozer 无法构建 apk,命令失败:./distribute.sh -m “kivy"d 2022-01-01
- 如何让对象对 Cocos2D 中的触摸做出反应? 2022-01-01
- 如何在 UIImageView 中异步加载图像? 2022-01-01