2017-07-12 147 views
1

我想在我的应用程序中添加一些动画。当我点击一个按钮时,我想显示一个圆圈。Swift动画 - 按钮后面的圆圈

enter image description here enter image description here

我真的不知道有什么能做到这一点的最好办法。

我是否必须在故事板上创建具有背景的视图,然后添加角半径并使用isHidden属性?

我是否必须以编程方式创建圆?也许更好,因为我有很多按钮?

+0

你听说过'UIButtonState'吗?您可以为按钮的高亮状态设置圆形图像。这将适用于你的情况 –

+0

即使按钮已经是一个图像?? – KevinB

+1

您可以为按钮的不同状态设置不同的背景图像。不要与'image'和'backgroundImage'混淆# –

回答

3

最好的方式,

DEMO

enter image description here

1.资产用于

enter image description here

enter image description here

enter image description here

  • 设置默认图像上Default StateUIButton
  • enter image description here

  • 组突出显示的对图像Highlighted State of UIButton
  • enter image description here

    +0

    非常感谢您的回答!但是我很抱歉,这并不是我想要的:/ ..我希望获得与pinterest相同的效果:当我们触摸按钮时,图标有一个小小的比例,而且是一个放大后面的圆圈。 (对不起,我的英文版) – KevinB

    +0

    当按高亮显示按钮时,你将不得不使用'CGAffineTransform scale API'来缩放它。 –

    +0

    如果我说得不好,我很抱歉,但我想说我想说2不同的动画(圆圈)和里面的图标。 – KevinB