記錄一下POP使用時(shí)遇到的問題

FaceBook的POP的動(dòng)畫框架確實(shí)挺好看的,使用起來(lái)也很簡(jiǎn)單。在使用的時(shí)候有幾個(gè)點(diǎn),也要注意一下。

- (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;
//        }
//    };
    
}

碰到了一個(gè)這樣的bug,當(dāng)一個(gè)POP動(dòng)畫還沒有結(jié)束,發(fā)起另外一個(gè)POP動(dòng)畫同時(shí)使用frame值去恢復(fù)button的初始狀態(tài),會(huì)發(fā)現(xiàn)這時(shí)候設(shè)置frame值無(wú)效。 (猜想可能跟pop實(shí)現(xiàn)機(jī)制有關(guān)系)

修改前.gif

解決方法:
1.使用上面代碼注釋中的self.userInteractionEnabled = YES;方法解決,這種解決方案會(huì)讓用戶體驗(yàn)非常差!
2.同樣使用POP動(dòng)畫還原按鈕狀態(tài),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
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

  • 1、通過(guò)CocoaPods安裝項(xiàng)目名稱項(xiàng)目信息 AFNetworking網(wǎng)絡(luò)請(qǐng)求組件 FMDB本地?cái)?shù)據(jù)庫(kù)組件 SD...
    陽(yáng)明AI閱讀 16,186評(píng)論 3 119
  • 文/孤鳥差魚 一場(chǎng)富人的游戲 唯獨(dú)對(duì)愛 開的條件 優(yōu)渥
    孤鳥差魚閱讀 230評(píng)論 0 3
  • 別理解我 我自己都不理解我 別注意我 我從沒時(shí)間注意我 別贊美我 我都沒資格贊美我 別嘲笑我 我很喜歡現(xiàn)在的我 我...
    蠢謙閱讀 305評(píng)論 0 1
  • 最近在部署項(xiàng)目啟動(dòng)tomcat的時(shí)候,發(fā)現(xiàn)啟動(dòng)超慢,啟動(dòng)一次要4-5分鐘。在查看tomcat的日志的時(shí)候看到:WA...
    半畝荒地閱讀 479評(píng)論 0 0
  • 已經(jīng)忘了幾號(hào)到的訓(xùn)練營(yíng),只知道每時(shí)每刻都有新的收獲,有理論的,有實(shí)踐的,在這里的學(xué)習(xí)是為了日后回到工作崗...
    居然電器城韓瑞萍1863568閱讀 293評(píng)論 0 0

友情鏈接更多精彩內(nèi)容