讓UIView有彈性移動,UIView有彈性移動

來源:互聯網
上載者:User

讓UIView有彈性移動,UIView有彈性移動
讓UIView有彈性移動by 伍雪穎

[UIView animateWithDuration:1 delay:0.0 usingSpringWithDamping:0.5 initialSpringVelocity:0 options:UIViewAnimationOptionLayoutSubviews animations:^{        _moveView.top = 400;    } completion:^(BOOL finished) {        _moveView.top = 100;}];



Objective-C有沒有UIView的動畫?怎讓一個view從螢幕上方滑下?

animated:YES,就是啟用動畫效果。Objective—c寫的程式都在控制台運行,學到IOS裡面才有動畫這些概念。至於view移動,這個肯定沒問題。寫個函數,使得view的frame的原點改變,或者中心點改變都可以,用個定時器,觸發後,座標一直遞增最終到達目標座標,停止定時器。自己多44了。學的時間久了,自然就知道,不要心急
 
怎讓圖片按軌跡勻速移動?

問題解決啦,貼出代碼CGPoint point = CGPointFromString([PointArray objectAtIndex:number]); float durationTime = [self distanceBetweenTwoPoint:protagonist.center point2:point]/MOVE_VELOCITY; [UIView animateWithDuration:durationTime delay:0 opti*****:UIViewAnimationCurveLinear animati*****:^{ [UIView setAnimationCurve:UIViewAnimationCurveLinear]; protagonist.center = point; }completion:^(BOOL finished) { if (finished) { int currentPointNumber = number + 1; [self protagonistMove:PointArray protagonist:protagonist number:currentPointNumber]; } }]; }
 

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.