文章搬运来源:https://www.jianshu.com/p/4c7b65ddead6
作者:季末微夏
对iOS开发感兴趣,可以看一下作者的iOS交流群:812157648,大家可以在里面吹水、交流相关方面的知识,群里还有我整理的有关于面试的一些资料,欢迎大家加群,大家一起开车
前言
说到APP用户体验,就离不开动画。在这篇文章里,简单实现了点击一个按钮弹出多个按钮的动画,在此抛砖引玉,供大家参考。
思路
首先创建需要被弹出的多个按钮,然后创建点击弹出的POP按钮,将其覆盖在多个按钮之上,最后在POP按钮点击事件里边利用UIView动画和CABasicAnimation动画,就可以实现简单的弹出效果。
主要代码
创建UI,这里使用数组来装多个按钮,方便后面取用。
@interface ViewController ()
/**弹出按钮 */
@property (nonatomic,strong) UIButton *popButton;
/**按钮数组*/
@property (nonatomic,strong) NSMutableArray *buttonArray;
@end
@implementation ViewController
- (UIButton *) popButton
{
if (_popButton == nil)
{
_popButton = [[UIButton alloc]initWithFrame:CGRectMake(self.view.centerX - 30, self.view.centerY - 30 + 180, 60, 60)];
[self.view addSubview:_popButton];