讓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]; } }]; }