美文网首页
记录一下POP使用时遇到的问题

记录一下POP使用时遇到的问题

作者: makemake | 来源:发表于2018-09-09 23:08 被阅读22次

FaceBook的POP的动画框架确实挺好看的,使用起来也很简单。在使用的时候有几个点,也要注意一下。

- (void)clickBottomButtonAction:(UIButton *)sender{

//    self.userInteractionEnabled = NO;
    for (UIButton *button in self.bottomButtonArray) {
        CGRect frame = button.frame;
        frame.origin.y = _originY;
        button.frame = frame;
        button.selected = NO;
    }
    sender.selected = YES;
    POPSpringAnimation *anSpring = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
    anSpring.fromValue = @(_originY);
    anSpring.toValue = @(_originY+10);
    anSpring.delegate = self;
    anSpring.springBounciness = 20.0f;
    [sender pop_addAnimation:anSpring forKey:[NSString stringWithFormat:@"BottomButtonPositionY%ldld",(long)sender.tag]];
//    anSpring.completionBlock = ^(POPAnimation *anim, BOOL finished) {
//        if (finished) {
//            self.userInteractionEnabled = YES;
//        }
//    };
    
}

碰到了一个这样的bug,当一个POP动画还没有结束,发起另外一个POP动画同时使用frame值去恢复button的初始状态,会发现这时候设置frame值无效。 (猜想可能跟pop实现机制有关系)

修改前.gif

解决方法:
1.使用上面代码注释中的self.userInteractionEnabled = YES;方法解决,这种解决方案会让用户体验非常差!
2.同样使用POP动画还原按钮状态,demo如下:

    if (_selectButton) {
        self.selectButton.selected = NO;
        POPBasicAnimation *anSpring = [POPBasicAnimation animationWithPropertyNamed:kPOPLayerPositionY];
        CGFloat h = self.selectButton.frame.size.height/6;
        anSpring.toValue =  @(SCREEN_HEIGHT-h);
        [self.selectButton pop_addAnimation:anSpring forKey:[NSString stringWithFormat:@"BottomButtonPositionY%ld",(long)self.selectButton.tag]];
    }
    
    self.selectButton = sender;
    sender.selected = YES;
    POPSpringAnimation *anSpring = [POPSpringAnimation animationWithPropertyNamed:kPOPLayerPositionY];
    anSpring.fromValue = @(_originY);
    anSpring.toValue = @(_originY+10);
    anSpring.springBounciness = 20.0f;
    [sender pop_addAnimation:anSpring forKey:[NSString stringWithFormat:@"BottomButtonPositionY%ld",(long)sender.tag]];
修改后.gif

相关文章

  • 记录一下POP使用时遇到的问题

    FaceBook的POP的动画框架确实挺好看的,使用起来也很简单。在使用的时候有几个点,也要注意一下。 碰到了一个...

  • Flutter pop到指定页面

    遇到一个指定返回问题这里记录一下需求:登录页->首页->功能页->详情页 <=> 详情页->首页 如上代码pop...

  • TG使用问题

    记录一下Telegram使用时碰到的问题,有点郁闷~

  • NSInvocation使用时遇到的问题记录

    前言 至于为什么要使用NSInvocation,由于在项目中Debug模式下加一个FLEX的开关,但是在打包上架时...

  • Figen GET传参遇到的问题以及解决方法

    今天学习feigen遇到了一些问题,在此记录一下。 feigen用GET方式传递对象的时候遇到405错误。 配置使...

  • Selenium的那些事

    这是在简书上写的第一篇文章,用来记录一下使用Selenium过程中遇到的点滴问题。 一、页面滚动遇到frame 使...

  • Facebook 开源动画库 POP

    使用时 在Podfile文件里添加 在文件中引入头文件 在使用时 创建一个pop类 学习pop的demohttp...

  • vue-cli3-element-ui select选择器,po

    前言 在项目中遇到的问题,修改selecet选择器,popover弹出框的样式时失效,在这里记录录一下,方便以后使...

  • Flutter - 记录一下遇到的问题

    1.保持页面状态 在使用tabbar切换页面时发现每次页面都会被重置刷新,flutter中提供了Automatic...

  • 设计循环队列

    最近从头开始刷 LeetCode 算法题,遇到这个,记录一下:题干: 执行用时分布图表:

网友评论

      本文标题:记录一下POP使用时遇到的问题

      本文链接:https://www.haomeiwen.com/subject/nbynwftx.html