本篇文章為大家展示了iOS中怎么實(shí)現(xiàn)數(shù)字倍數(shù)動(dòng)畫(huà)效果,內(nèi)容簡(jiǎn)明扼要并且容易理解,絕對(duì)能使你眼前一亮,通過(guò)這篇文章的詳細(xì)介紹希望你能有所收獲。
站在用戶(hù)的角度思考問(wèn)題,與客戶(hù)深入溝通,找到金口河網(wǎng)站設(shè)計(jì)與金口河網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶(hù)體驗(yàn)好的作品,建站類(lèi)型包括:做網(wǎng)站、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、主機(jī)域名、虛擬空間、企業(yè)郵箱。業(yè)務(wù)覆蓋金口河地區(qū)。// 數(shù)字跳動(dòng)動(dòng)畫(huà)- (void)labelDanceAnimation:(NSTimeInterval)duration { //透明度 CABasicAnimation *opacityAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"]; opacityAnimation.duration = 0.4 * duration; opacityAnimation.fromValue = @0.f; opacityAnimation.toValue = @1.f; //縮放 CAKeyframeAnimation *scaleAnimation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"]; scaleAnimation.duration = duration; scaleAnimation.values = @[@3.f, @1.f, @1.2f, @1.f]; scaleAnimation.keyTimes = @[@0.f, @0.16f, @0.28f, @0.4f]; scaleAnimation.removedOnCompletion = YES; scaleAnimation.fillMode = kCAFillModeForwards; CAAnimationGroup *animationGroup = [CAAnimationGroup animation]; animationGroup.animations = @[opacityAnimation, scaleAnimation]; animationGroup.duration = duration; animationGroup.removedOnCompletion = YES; animationGroup.fillMode = kCAFillModeForwards; [self.comboLabel.layer addAnimation:animationGroup forKey:@"kComboAnimationKey"];}
利用一個(gè)透明度從 0 ~ 1之間的alpha,然后縮放 之后加到動(dòng)畫(huà)組實(shí)現(xiàn)一下就好了
切記動(dòng)畫(huà)完成好移除 否則可能引起動(dòng)畫(huà)內(nèi)存問(wèn)題
這里設(shè)置斜體字體
self.comboLabel.font = [UIFont fontWithName:@"AvenirNext-BoldItalic" size:50];
看著比較明顯
最后按鈕點(diǎn)擊的時(shí)候調(diào)用
- (IBAction)clickAction:(UIButton *)sender { self.danceCount++; [self labelDanceAnimation:0.4]; self.comboLabel.text = [NSString stringWithFormat:@"+ %tu",self.danceCount];}
上述內(nèi)容就是iOS中怎么實(shí)現(xiàn)數(shù)字倍數(shù)動(dòng)畫(huà)效果,你們學(xué)到知識(shí)或技能了嗎?如果還想學(xué)到更多技能或者豐富自己的知識(shí)儲(chǔ)備,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道。