private async void AnimateShow() { LayoutIfNeeded(); if (_dialogView.Subviews.Length > 0) { if (_dialogView.Subviews.Length == 1) { _dialogHeight = (float)_dialogView.Subviews[0].Frame.Bottom - (float)_dialogView.Subviews[0].Frame.Top; } else { _dialogHeight = (float)_dialogView.Subviews[_dialogView.Subviews.Length - 1].Frame.Bottom - (float)_dialogView.Subviews[0].Frame.Top; } } _dialogHeight += _dialogEdgeConstraint * 2; var y = (UIScreen.MainScreen.Bounds.Height - _dialogHeight) / 2; if (_isPrompt) { y = 50f; CustomInputView.BecomeFirstResponder(); } _dialogView.Frame = new CGRect(_dialogView.Frame.X, y, _dialogView.Frame.Width, _dialogHeight); LayoutIfNeeded(); await UIView.AnimateAsync(0.3, () => { _dialogView.Alpha = 1; }); }
public override void ViewDidLoad() { base.ViewDidLoad(); viewModel = new ImageSearchViewModel(); CollectionViewImages.WeakDataSource = this; ButtonSearch.TouchUpInside += async(sender, args) => { ButtonSearch.Enabled = false; ActivityIsLoading.StartAnimating(); // iOS 빌트인 애니메이션 await UIView.AnimateAsync(1.0, () => CollectionViewImages.Alpha = 0); // Shared 코드 호출 await viewModel.SearchForImagesAsync(TextFieldQuery.Text); CollectionViewImages.ReloadData(); await UIView.AnimateAsync(1.0, () => CollectionViewImages.Alpha = 1); ActivityIsLoading.StopAnimating(); ButtonSearch.Enabled = true; }; SetupCamera(); }
public async Task StartAnimation() { if (CoffeeImage.Image != RegularCoffeeImage) { ShowSteamAndCoffee = false; CoffeeImage.Image = RegularCoffeeImage; } await UIView.AnimateAsync(0.2, () => Alpha = 1); await UIView.AnimateAsync(1.0, () => { coffee.Frame = fullCoffee; steam.Alpha = 1; }); await Task.Delay(100); await UIView.AnimateAsync(1.0, () => { coffee.Frame = emptyCoffee; steam.Alpha = 0; }); if (ShowSadCoffee) { LoopAnimation = false; ShowSteamAndCoffee = true; CoffeeImage.Image = SadCoffeeImage; return; } if (LoopAnimation) { StartAnimation(); } }
private async void TapAnimation(double duration, double start = 1, double end = 0, bool remove = true) { if (!IsDisposed && _layer != null) { _cancellation?.Cancel(); _cancellation = new CancellationTokenSource(); var token = _cancellation.Token; _layer.Frame = new CGRect(0, 0, Container.Bounds.Width, Container.Bounds.Height); Container.AddSubview(_layer); Container.BringSubviewToFront(_layer); _layer.Alpha = (float)start; await UIView.AnimateAsync(duration, () => { if (!token.IsCancellationRequested && !IsDisposed) { _layer.Alpha = (float)end; } }); if (remove && !IsDisposed && !token.IsCancellationRequested) { _layer?.RemoveFromSuperview(); } } }
public void Disassemble() { animated = false; UIView.Animate(.75, () => { var frame = new RectangleF(head.Frame.X, -100, head.Frame.Width, head.Frame.Height); head.Frame = frame; frame = new RectangleF(-100, leftArm.Frame.Y, leftArm.Frame.Width, leftArm.Frame.Height); leftArm.Frame = frame; frame = new RectangleF(rightArm.Frame.Size.Width + 100, rightArm.Frame.Y, rightArm.Frame.Width, rightArm.Frame.Height); rightArm.Frame = frame; frame = new RectangleF(leftLeg.Frame.X - 50, leftLeg.Frame.Size.Height, leftLeg.Frame.Width, leftLeg.Frame.Height); leftLeg.Frame = frame; frame = new RectangleF(rightLeg.Frame.X + 50, rightLeg.Frame.Size.Height, rightLeg.Frame.Width, rightLeg.Frame.Height); rightLeg.Frame = frame; }, async() => { await UIView.AnimateAsync(.5, () => { this.Alpha = 0; }); RemoveFromSuperview(); }); }
public static async Task AnimateAsync(this UIView view, IAnimation animation) { if (animation is TransformAnimation transformAnimation) { var source = new TaskCompletionSource <bool>(); view.Alpha = transformAnimation.From.Opacity; view.Transform = transformAnimation.From.ToNative(view.Bounds.Size); UIView.Animate(animation.Duration.TotalSeconds, animation.Delay.TotalSeconds, transformAnimation.Curve.ToNative(), () => { view.Alpha = transformAnimation.To.Opacity; view.Transform = transformAnimation.To.ToNative(view.Bounds.Size); }, () => source.SetResult(true)); await source.Task; } else if (animation is SequenceAnimation sequenceAnimation) { foreach (var childAnimation in sequenceAnimation) { await view.AnimateAsync(childAnimation); } } }
/* * Slides the bottom sheet in from the right of the frame */ public async Task slideMenuBackInFromRight() { await UIView.AnimateAsync(0.3, new Action(() => { var frame = this.View.Frame; this.View.Frame = new CGRect(0, frame.Y, frame.Width, frame.Height); })); }
public void ButtonFinished(ButtonView button, UIView trackingView, UITouch location) { double delayInSeconds; buttonDraggedToPad = false; miniPadView.Layer.BorderWidth = 0; CGPoint point = location.LocationInView(miniPadView); if (miniPadView.PointInside(point, null)) { UpdateScoreForDroppedButton(button); UIView.Animate(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(10f * (float)Math.PI / 180), async() => { await UIView.AnimateAsync(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(-10f * (float)Math.PI / 180)); await UIView.AnimateAsync(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(10f * (float)Math.PI / 180)); await UIView.AnimateAsync(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(-10f * (float)Math.PI / 180)); await UIView.AnimateAsync(.1f, () => trackingView.Transform = CGAffineTransform.MakeRotation(0)); }); } delayInSeconds = 0.5; var popTime = new DispatchTime(DispatchTime.Now, (long)(delayInSeconds * NSEC_PER_SEC)); DispatchQueue.MainQueue.DispatchAfter(popTime, async() => { await UIView.AnimateAsync(0.35f, () => { CGRect bounds = trackingView.Bounds; bounds.Size = new CGSize(10, 10); trackingView.Bounds = bounds; }); trackingView.RemoveFromSuperview(); }); }
public async override void TouchesEnded(Foundation.NSSet touches, UIEvent evt) { base.TouchesEnded(touches, evt); AddPoint(touches); // Start the recognition var item = recognizer.Recognize(allPoints); string display = string.Format("{0} - {1}, {2}", item.Name, item.Score, item.IndicativeAngleInDegrees); NavigationItem.Prompt = display; UILabel lbl = new UILabel(); lbl.Frame = new CGRect(item.BoundingRectangle.X, item.BoundingRectangle.Y, item.BoundingRectangle.Width, item.BoundingRectangle.Height); lbl.BackgroundColor = UIColor.FromRGBA(0, 0, 255, 100); lbl.Lines = 0; lbl.LineBreakMode = UILineBreakMode.CharacterWrap; lbl.Text = display; Add(lbl); await Task.Delay(4000); await UIView.AnimateAsync(0.4, () => { lbl.Alpha = 0; }); lbl.RemoveFromSuperview(); }
public void MoveArms() { if (!animated) { return; } float armRotation = 10 * (float)Math.PI / 180; UIView.Animate(1.75, () => { rightArm.Transform = CGAffineTransform.MakeRotation(armRotation); leftArm.Transform = CGAffineTransform.MakeRotation(-armRotation); }, async() => { if (!animated) { return; } await UIView.AnimateAsync(1.75, () => { rightArm.Transform = CGAffineTransform.MakeIdentity(); leftArm.Transform = CGAffineTransform.MakeIdentity(); }); MoveArms(); }); }
private async void TapAnimation(double duration, double start = 1, double end = 0, bool remove = true) { if (!IsDisposed && _layer != null) { _cancellation?.Cancel(); _cancellation = new CancellationTokenSource(); var token = _cancellation.Token; _layer.Layer.RemoveAllAnimations(); _layer.Alpha = (float)start; //View.BringSubviewToFront(_layer); //UpdateEffectColor(); await UIView.AnimateAsync(duration, () => { if (!token.IsCancellationRequested && !IsDisposed) { _layer.Alpha = (float)end; } }); //if (remove && !IsDisposed && !token.IsCancellationRequested) //{ // _layer?.RemoveFromSuperview(); //} } }
public override async void AnimateTransition(IUIViewControllerContextTransitioning transitionContext) { // Get the from and to View Controllers and their views var fromVC = transitionContext.GetViewControllerForKey(UITransitionContext.FromViewControllerKey); var fromView = fromVC.View; var toVC = transitionContext.GetViewControllerForKey(UITransitionContext.ToViewControllerKey); var toView = toVC.View; // Add the to view to the transition container view var containerView = transitionContext.ContainerView; // Set the desired target for the transition var appearedFrame = transitionContext.GetFinalFrameForViewController(fromVC); // Set how the animation shall end var finalFrame = new CGRect(_animationOrigin.Frame.GetMidX(), _animationOrigin.Frame.GetMidY(), 0, 0); fromView.Frame = appearedFrame; var isAnimationCompleted = await UIView.AnimateAsync(TransitionDuration(transitionContext), () => { fromView.Frame = finalFrame; }); fromView.RemoveFromSuperview(); transitionContext.CompleteTransition(isAnimationCompleted); }
void UpdateSelectedBarPositionWithAnimation(bool animation) { CGRect frame = SelectedBar.Frame; if (DataSource == null) { return; } UICollectionViewCell cell = this.DataSource.GetCell(this, NSIndexPath.FromItemSection(_selectedOptionIndex, 0)); UpdateContentOffset(cell); frame.Width = cell.Frame.Size.Width; frame.Location = new CGPoint(cell.Frame.X, frame.Location.Y); if (animation) { UIView.AnimateAsync(0.2, () => { SelectedBar.Frame = frame; }); } else { SelectedBar.Frame = frame; } }
private void HandleAlphaFadeIn(NSNotification obj) { NSDictionary parameters = obj.UserInfo; NSObject objectFade = parameters[NSObject.FromObject("fadeIn")]; string objectFadeParameter = objectFade.ToString(); int fadeNumber = ConvertUtil.ConvertStringToInt(objectFadeParameter); NSObject objectView = parameters[NSObject.FromObject("view")]; string objectViewParameter = objectView.ToString(); int view = ConvertUtil.ConvertStringToInt(objectViewParameter); nfloat value = 0.0f; if (fadeNumber == 1) { value = 1.0f; } InvokeOnMainThread(async delegate { if (value != lastAlpha || view != lastView) { lastAlpha = value; lastView = view; await UIView.AnimateAsync(0.5, () => { this.View.Subviews[0].Alpha = value; }); } }); }
public void MoveLegs() { if (!animated) { return; } float legRotation = (float)(Math.PI / 4 * .35); UIView.Animate(2.5, () => { rightLeg.Transform = CGAffineTransform.MakeRotation(legRotation); leftLeg.Transform = CGAffineTransform.MakeRotation(-legRotation); }, async() => { if (!animated) { return; } await UIView.AnimateAsync(2.5, () => { rightLeg.Transform = CGAffineTransform.MakeRotation(-legRotation); leftLeg.Transform = CGAffineTransform.MakeRotation(legRotation); }); MoveLegs(); }); }
async void HideSecond(bool animated) { if (!ChildViewControllers.Contains(Second)) { return; } Second.ViewWillDisappear(animated); containerView.OnlyFirst = true; containerView.SetNeedsLayout(); if (animated) { await UIView.AnimateAsync(0.333, () => { Second.View.Alpha = 0.0f; Splitter.Alpha = 0.0f; containerView.LayoutIfNeeded(); }); } else { Second.View.Alpha = 0.0f; Splitter.Alpha = 0.0f; } Second.RemoveFromParentViewController(); Second.View.RemoveFromSuperview(); Splitter.RemoveFromSuperview(); containerView.SetNeedsLayout(); }
async void ShowSecond(bool animated) { if (ChildViewControllers.Contains(Second)) { return; } if (PresentedViewController != null) { await DismissViewControllerAsync(animated); } Second.View.Alpha = animated ? 0.0f : 1.0f; Splitter.Alpha = animated ? 0.0f : 1.0f; Second.ViewWillAppear(animated); AddChildViewController(Second); containerView.AddSubview(Second.View); containerView.AddSubview(Splitter); containerView.OnlyFirst = false; containerView.SetNeedsLayout(); if (animated) { await UIView.AnimateAsync(0.333, () => { Second.View.Alpha = 1.0f; Splitter.Alpha = 1.0f; containerView.LayoutIfNeeded(); }); } }
public void HandleTouch(TouchStatus status, UserInteractionState?userInteractionState = null) { if (IsCanceled || _effect == null) { return; } if (_effect?.IsDisabled ?? true) { return; } _effect.HandleTouch(status); if (userInteractionState.HasValue) { _effect?.HandleUserInteraction(userInteractionState.Value); } if (_effect == null || !_effect.NativeAnimation || !_effect.CanExecute) { return; } var control = _effect.Control; var renderer = control?.GetRenderer() as UIView; if (renderer == null) { return; } var color = _effect.NativeAnimationColor; var radius = _effect.NativeAnimationRadius; var shadowRadius = _effect.NativeAnimationShadowRadius; var isStarted = status == TouchStatus.Started; _defaultRadius = (float?)(_defaultRadius ?? renderer.Layer.CornerRadius); _defaultShadowRadius = (float?)(_defaultShadowRadius ?? renderer.Layer.ShadowRadius); _defaultShadowOpacity = _defaultShadowOpacity ?? renderer.Layer.ShadowOpacity; UIView.AnimateAsync(.2, () => { if (color == Color.Default) { renderer.Layer.Opacity = isStarted ? 0.5f : (float)control.Opacity; } else { renderer.Layer.BackgroundColor = (isStarted ? color : control.BackgroundColor).ToCGColor(); } renderer.Layer.CornerRadius = isStarted ? radius : _defaultRadius.GetValueOrDefault(); if (shadowRadius >= 0) { renderer.Layer.ShadowRadius = isStarted ? shadowRadius : _defaultShadowRadius.GetValueOrDefault(); renderer.Layer.ShadowOpacity = isStarted ? 0.7f : _defaultShadowOpacity.GetValueOrDefault(); } }); }
async partial void OnToggleClicked(NSObject sender) { if (toggling) { return; } toggling = true; if (toggleIsOpen) { ToggleButton.Image = UIImage.FromBundle("toggle"); parameterList.ViewWillDisappear(true); await UIView.AnimateAsync(.3, () => { View.Frame = new CGRect(0, 0, View.Frame.Width + 200, View.Frame.Height); parameterList.View.Frame = new CGRect(-200, 0, 200, View.Frame.Height); View.LayoutIfNeeded(); // For speed we just redraw the showing plot //plotScene.RedrawCurrentPlot(); }); // After the animation is done, we start redrawing all the plots //plotScene.SetUpPlot(false); toggleIsOpen = false; parameterList.ViewDidDisappear(true); } else { ToggleButton.Image = UIImage.FromBundle("untoggle"); if (firstTime) { View.Superview.AddSubview(parameterList.View); firstTime = false; } parameterList.ViewWillAppear(true); await UIView.AnimateAsync(.3, () => { View.Frame = new CGRect(200, 0, View.Frame.Width - 200, View.Frame.Height); parameterList.View.Frame = new CGRect(0, 0, 200, View.Frame.Height); View.LayoutIfNeeded(); // For speed we just redraw the showing plot //plotScene.RedrawCurrentPlot(); }); // After the animation is done, we start redrawing all the plots //plotScene.SetUpPlot(false); toggleIsOpen = true; parameterList.ViewDidAppear(true); } toggling = false; }
void KeyboardWillHide(NSNotification notification) { UIView.AnimateAsync(0.3, () => { var f = this.View.Frame; f.Y = 0.0f; this.View.Frame = f; }); }
/* * Slides the bottom sheet to the left of the frame */ public async Task slideMenuToLeft() { await UIView.AnimateAsync(0.3, new Action(() => { var frame = this.View.Frame; var xComponent = UIScreen.MainScreen.Bounds.Width; this.View.Frame = new CGRect(-xComponent, frame.Y, frame.Width, frame.Height); })); }
/* * Closes the bottom sheet to the bottom of the frame */ public async Task closeMenu() { await UIView.AnimateAsync(0.5, new Action(() => { var frame = this.View.Frame; var yComponent = UIScreen.MainScreen.Bounds.Height; this.View.Frame = new CGRect(frame.X, yComponent, frame.Width, frame.Height); })); }
private void LevelUp() { //Animates level up for the user. InvokeOnMainThread(delegate { LevelUpLabel.Alpha = 1; UIView.AnimateAsync(2, animation: () => { LevelUpLabel.Alpha = 0; }); }); }
/* * Opens the menu from the bottom of the screen */ public async Task OpenMenu() { await UIView.AnimateAsync(0.3, new Action(() => { var frame = this.View.Frame; //var yComponent = UIScreen.MainScreen.Bounds.Height - 200; var yComponent = this.partialView; this.View.Frame = new CGRect(0, yComponent, frame.Width, frame.Height); })); }
public static Task FadeAnimatedAsync(this UIView view, nfloat from, nfloat to, nfloat duration) { return(UIView.AnimateAsync( duration, () => { view.Alpha = from; view.Alpha = to; })); }
async Task HideToast() { await UIView.AnimateAsync(0.5, () => { toastContainer.Alpha = 0.0f; }); toastContainer.RemoveFromSuperview(); isVisible = false; }
internal async void SetSelected(bool selected, bool animated, Action completion) { float length = animated ? _AnimationLength : 0.0f; float alpha = selected ? 1.0f : 0.0f; await UIView.AnimateAsync(length, new NSAction (() => SelectedView.Alpha = alpha)); /*UIView.Animate (length, 0, UIViewAnimationOptions.CurveEaseInOut, * new NSAction (() => SelectedView.Alpha = alpha), * new NSAction (completion));*/ }
public override async void WillDisplay(UITableView tableView, UITableViewCell cell, NSIndexPath indexPath) { cell.Alpha = 0; cell.Layer.Transform = CATransform3D.MakeTranslation(-500, 0, 0); await UIView.AnimateAsync(0.5, () => { cell.Alpha = 1; cell.Layer.Transform = CATransform3D.Identity; }); }
public async Task Hide() { CGRect frame = Frame; frame.Y = -frame.Size.Height; await UIView.AnimateAsync(.35, () => { Frame = frame; }); HelpDidClose(this); }
async void OnTouchEnd(object sender, EventArgs e) { if (!(Element is VisualElement visualElement) || !visualElement.IsEnabled) { return; } await UIView.AnimateAsync(0.5, () => { _layer.Alpha = 0; }); }