如何为NSImageView中的内容开关设置动画效果? [英] How can I animate a content switch in an NSImageView?

查看:214
本文介绍了如何为NSImageView中的内容开关设置动画效果?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想切换 NSImageView 中显示的图片,但我想为该变更设定动画。我尝试了各种方法来做到这一点。希望你们中的一个可以建议一个可能实际工作。我正在与Cocoa for Mac合作。

I want to switch the image shown in an NSImageView, but I want to animate that change. I've tried various methods to do this. Hopefully one of you could suggest one that might actually work. I'm working with Cocoa for Mac.

推荐答案

您可以实现自己的使用Core动画的自定义视图 CALayer 以存储图像。当您设置图层的 contents 属性时,图片将自动平滑地从旧图片动画到新图片。

You could implement your own custom view that uses a Core Animation CALayer to store the image. When you set the contents property of the layer, the image will automatically smoothly animate from the old image to the new one.

这篇关于如何为NSImageView中的内容开关设置动画效果?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆