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
- MalformedJsonException:在第1行第1列路径中使用JsonReader.setLenient(True)接受格式错误的JSON 2022-01-01
- Android - 拆分 Drawable 2022-01-01
- 如何检查发送到 Android 应用程序的 Firebase 消息的传递状态? 2022-01-01
- Android viewpager检测滑动超出范围 2022-01-01
- Android - 我如何找出用户有多少未读电子邮件? 2022-01-01
- 使用自定义动画时在 iOS9 上忽略 edgesForExtendedLayout 2022-01-01
- 用 Swift 实现 UITextFieldDelegate 2022-01-01
- 想使用ViewPager,无法识别android.support.*? 2022-01-01
- android 4中的android RadioButton问题 2022-01-01
- 在测试浓缩咖啡时,Android设备不会在屏幕上启动活动 2022-01-01