第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

如何沿曲線路徑設(shè)置視圖或圖像的移動(dòng)動(dòng)畫?

如何沿曲線路徑設(shè)置視圖或圖像的移動(dòng)動(dòng)畫?

忽然笑 2019-08-09 14:28:00
如何沿曲線路徑設(shè)置視圖或圖像的移動(dòng)動(dòng)畫?我正在開發(fā)一個(gè)商務(wù)應(yīng)用程序。當(dāng)我將一個(gè)項(xiàng)目添加到購物車時(shí),我想創(chuàng)建一個(gè)效果,其中項(xiàng)目的圖像遵循彎曲的路徑,最終在購物車選項(xiàng)卡上。如何沿這樣的曲線創(chuàng)建圖像動(dòng)畫?
查看完整描述

3 回答

?
互換的青春

TA貢獻(xiàn)1797條經(jīng)驗(yàn) 獲得超6個(gè)贊

為了擴(kuò)展Nikolai所說的,處理這個(gè)問題的最佳方法是使用Core Animation為Bezier路徑上的圖像或視圖的運(yùn)動(dòng)設(shè)置動(dòng)畫。這是使用CAKeyframeAnimation完成的。例如,我使用以下代碼將視圖圖像設(shè)置為圖標(biāo)以指示保存(如此應(yīng)用程序視頻中所示):

首先導(dǎo)入QuartzCore頭文件 #import <QuartzCore/QuartzCore.h>

UIImageView *imageViewForAnimation = [[UIImageView alloc] initWithImage:imageToAnimate];

imageViewForAnimation.alpha = 1.0f;

CGRect imageFrame = imageViewForAnimation.frame;

//Your image frame.origin from where the animation need to get start

CGPoint viewOrigin = imageViewForAnimation.frame.origin;

viewOrigin.y = viewOrigin.y + imageFrame.size.height / 2.0f;

viewOrigin.x = viewOrigin.x + imageFrame.size.width / 2.0f;


imageViewForAnimation.frame = imageFrame;

imageViewForAnimation.layer.position = viewOrigin;

[self.view addSubview:imageViewForAnimation];


// Set up fade out effect

CABasicAnimation *fadeOutAnimation = [CABasicAnimation animationWithKeyPath:@"opacity"];

[fadeOutAnimation setToValue:[NSNumber numberWithFloat:0.3]];

fadeOutAnimation.fillMode = kCAFillModeForwards;

fadeOutAnimation.removedOnCompletion = NO;


// Set up scaling

CABasicAnimation *resizeAnimation = [CABasicAnimation animationWithKeyPath:@"bounds.size"];

[resizeAnimation setToValue:[NSValue valueWithCGSize:CGSizeMake(40.0f, imageFrame.size.height * (40.0f / imageFrame.size.width))]];

resizeAnimation.fillMode = kCAFillModeForwards;

resizeAnimation.removedOnCompletion = NO;


// Set up path movement

CAKeyframeAnimation *pathAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];

pathAnimation.calculationMode = kCAAnimationPaced;

pathAnimation.fillMode = kCAFillModeForwards;

pathAnimation.removedOnCompletion = NO;

//Setting Endpoint of the animation

CGPoint endPoint = CGPointMake(480.0f - 30.0f, 40.0f);

//to end animation in last tab use 

//CGPoint endPoint = CGPointMake( 320-40.0f, 480.0f);

CGMutablePathRef curvedPath = CGPathCreateMutable();

CGPathMoveToPoint(curvedPath, NULL, viewOrigin.x, viewOrigin.y);

CGPathAddCurveToPoint(curvedPath, NULL, endPoint.x, viewOrigin.y, endPoint.x, viewOrigin.y, endPoint.x, endPoint.y);

pathAnimation.path = curvedPath;

CGPathRelease(curvedPath);


CAAnimationGroup *group = [CAAnimationGroup animation]; 

group.fillMode = kCAFillModeForwards;

group.removedOnCompletion = NO;

[group setAnimations:[NSArray arrayWithObjects:fadeOutAnimation, pathAnimation, resizeAnimation, nil]];

group.duration = 0.7f;

group.delegate = self;

[group setValue:imageViewForAnimation forKey:@"imageViewBeingAnimated"];


[imageViewForAnimation.layer addAnimation:group forKey:@"savingAnimation"];


[imageViewForAnimation release];


查看完整回答
反對 回復(fù) 2019-08-09
  • 3 回答
  • 0 關(guān)注
  • 809 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號