在 iPhone 上旋转图像的最快方法
我需要旋转 UIImage 以响应用户输入。 我希望它尽可能流畅,因此想知道哪种是执行转换和渲染的最快方法。 理想情况下,我想留在 UIKit 或 Quartz 框架内。 图像的属性如下:
- 大小约为 250x300 像素
- 不透明 - 需要使用 Alpha 通道渲染
实现此功能的最佳方法和实践是什么?
注意:stackoverflow 答案 但我不确定这是否是最佳的。 我当然会尝试一下,但我很想知道这是否被认为是“最佳实践”。
I need to rotate a UIImage in response to user input. I'd like this to be as slick as possible and therefore would like to know which is the quickest way to perform the transformation and render. Ideally I'd like to stay within the UIKit or Quartz frameworks. The properties of the image are as follows:
- Size approximately 250x300 pixels
- Not opaque - needs to render with an alpha channel
What are the best approaches and practices for implementing this functionality?
Note: There is an approach described in this stackoverflow answer but I am uncertain if this is optimal. I will of course give this a try but I'd be keen to know if this is considered to be the 'best practice'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
这个将核心动画层应用于 UIImage 的示例可能会提供一些启发:
This example of applying a Core Animation layer to a UIImage might provide some inspiration:
如果您在 UIImageView 中显示 UIImage,为什么不在视图上设置 Transform 属性呢?
就这么简单,对于像您所说的这样的小图像来说,这是高性能的 - 所有 UIKit 视图都是层支持的,因此它是硬件加速的。 该属性也是可动画的。
If you are displaying your UIImage in a UIImageView, why not just set the transform property on the view ?
It's as simple as that, and for a small image like your talking about this is highly performant - all UIKit views are layer backed, so it's hardware accelerated. This property is also animatable.