gpt4 book ai didi

iphone - 动画 UIButton 图像

转载 作者:行者123 更新时间:2023-12-03 20:27:02 26 4
gpt4 key购买 nike

我想在我的应用程序中为 UIButton 提供连续的“脉冲”效果,它通过一系列图像进行动画处理,然后通过这些相同的图像反转回来。我找到了 UIImageViews 使用其animationImages 属性的示例,但我发现的 UIButtons 的所有内容都是通过动画更改其 alpha。

UIView 方法 setAnimationRepeatAutoreverses 是我想要的循环,但我不明白如何在 UIButton 的动画 block 中使用图像数组。这是可能的还是推荐使用 NSTimer/setImage 方法?非常感谢任何示例。

最佳答案

虽然 subview 技术有效,但更简单的方法是仅在 UIButton 的 imageView 上设置 animationImages 属性。来自文档:

Although [the imageView] property is read-only, its own properties are read/write. Use these properties to configure the appearance and behavior of the button’s view.

例如:

self.pulsingButton.imageView.animationImages =
[NSArray arrayWithObjects:[UIImage imageNamed:@"button1.png"],
[UIImage imageNamed:@"button2.png"],
nil];

关于iphone - 动画 UIButton 图像,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1529720/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com