private async Task AnimateItem(View uiElement, uint duration ){ while (_animate) { await uiElement.ScaleTo(1.05, duration, Easing.SinInOut); await Task.WhenAll ( uiElement.FadeTo(1, duration, Easing.SinInOut), uiElement.LayoutTo (new Rectangle( new Point(0,0), new Size( uiElement.Width, uiElement.Height))), uiElement.FadeTo(.9, duration, Easing.SinInOut), uiElement.ScaleTo(1.15, duration, Easing.SinInOut) ); } }
private async Task Animate(Xamarin.Forms.View view, bool isCurrent) { //if (isCurrent) view.IsVisible = true; Rectangle beginRect = Rectangle.Zero; Rectangle endRect = Rectangle.Zero; //设置起始和终止值 beginRect = setbeginRect(isCurrent, _Direct); endRect = setendRect(isCurrent, _Direct); view.Layout(beginRect); await view.LayoutTo(endRect, easing : Easing.Linear) .ContinueWith(t => { // BUG 会使填充失效 view.IsVisible = isCurrent; }, TaskScheduler.FromCurrentSynchronizationContext()); }