public static void LoadingInView(string animationName, UIView view, bool shouldAnimate) { if (shouldAnimate) { view.Hidden = false; _lottieAnimation = LOTAnimationView.AnimationNamed(animationName); _lottieAnimation.Frame = new CGRect(0, 0, view.Frame.Width, view.Frame.Height); view.AddSubview(_lottieAnimation); _lottieAnimation.LoopAnimation = true; _lottieAnimation.Hidden = false; _lottieAnimation.AnimationProgress = 0; _lottieAnimation.Play(); } else { view.Hidden = true; if (_lottieAnimation != null) { _lottieAnimation.Hidden = true; _lottieAnimation.Pause(); _lottieAnimation?.Dispose(); _lottieAnimation = null; } } }
public void StopLoading() { _lottieAnimation?.Pause(); _lottieAnimation?.RemoveFromSuperview(); _lottieAnimation?.Dispose(); _lottieAnimation = null; }
public static void CustomButtomLoadingAnimation(string animation, UIButton button, string viewText, bool shouldAnimate) { if (shouldAnimate) { _lottieAnimation = LOTAnimationView.AnimationNamed(animation); _lottieAnimation.ContentMode = UIViewContentMode.ScaleAspectFit; _lottieAnimation.Frame = button.Frame; button.AddSubview(_lottieAnimation); _lottieAnimation.LoopAnimation = true; button.SetTitle("", UIControlState.Normal); _lottieAnimation.AnimationProgress = 0; _lottieAnimation.Hidden = false; _lottieAnimation.Play(); } else { if (_lottieAnimation != null) { _lottieAnimation.Hidden = true; _lottieAnimation.Pause(); _lottieAnimation?.Dispose(); _lottieAnimation = null; } button.SetTitle(viewText, UIControlState.Normal); } }
async void load(int idx) { foreach (var view in this.Container.Subviews) { view.RemoveFromSuperview(); } var url = ""; switch (idx) { case 0: url = "https://www.lottiefiles.com/storage/datafiles/jW5K6vtuzJFJSxd/data.json"; break; case 1: url = "https://www.lottiefiles.com/storage/datafiles/30e6f85b10d28931e85c2e0fcffa2f59/data.json"; break; case 2: default: url = "https://www.lottiefiles.com/storage/datafiles/8UjWgBkqvEF5jNoFcXV4sdJ6PXpS6DwF7cK4tzpi/Check%20Mark%20Success/Check%20Mark%20Success%20Data.json"; break; } LOTAnimationView animation = new LOTAnimationView(new Foundation.NSUrl(url)); animation.ContentMode = UIViewContentMode.ScaleAspectFit | UIViewContentMode.Center; animation.Frame = new CoreGraphics.CGRect(this.Container.Frame.X, this.Container.Frame.Y, this.Container.Frame.Width, this.Container.Frame.Height); this.Container.AddSubview(animation); this.Container.SetNeedsLayout(); animation.Play(); }
private void CommonInit() { ContentView = ViewFromNib(); NoDataLabel.Text = Localize.GetText("State.NoDate"); ContentView.Frame = Frame; ContentView.AutoresizingMask = UIViewAutoresizing.FlexibleHeight & UIViewAutoresizing.FlexibleWidth; AutoresizingMask = UIViewAutoresizing.FlexibleHeight & UIViewAutoresizing.FlexibleWidth; AddSubview(ContentView); TranslatesAutoresizingMaskIntoConstraints = false; ContentView.TranslatesAutoresizingMaskIntoConstraints = false; ContentView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor).Active = true; ContentView.TrailingAnchor.ConstraintEqualTo(TrailingAnchor).Active = true; ContentView.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active = true; ContentView.TopAnchor.ConstraintEqualTo(TopAnchor).Active = true; LOTAnimationView lottie = LOTAnimationView.AnimationNamed("no-data"); lottie.ContentMode = UIViewContentMode.ScaleAspectFit; LottieView.Frame = new CGRect(LottieView.Frame.X, LottieView.Frame.Y, Frame.Width, Frame.Width); lottie.Frame = LottieView.Frame; LottieView.AddSubview(lottie); lottie.SetFillXContraintTo(LottieView, 16); lottie.SetFillYContraintTo(LottieView, 16); lottie.SetBottomContraintTo(LottieView, 0, NSLayoutRelation.GreaterThanOrEqual); AddConstraint(NSLayoutConstraint.Create(lottie, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterY, 1, 0)); lottie.Play(); }
private void CommonInit() { ContentView = ViewFromNib(); ContentView.Frame = Frame; NoInternetLabel.Text = Localize.GetText("State.NoInternet.Message"); UpdateButton.TouchUpInside += (sender, e) => { RefreshCommand.Execute(); }; AddSubview(ContentView); ContentView.LeadingAnchor.ConstraintEqualTo(LeadingAnchor).Active = true; ContentView.TrailingAnchor.ConstraintEqualTo(TrailingAnchor).Active = true; ContentView.BottomAnchor.ConstraintEqualTo(BottomAnchor).Active = true; ContentView.TopAnchor.ConstraintEqualTo(TopAnchor).Active = true; LOTAnimationView lottie = LOTAnimationView.AnimationNamed("no-internet-connection"); lottie.ContentMode = UIViewContentMode.ScaleAspectFit; LottieView.Frame = new CGRect(LottieView.Frame.X, LottieView.Frame.Y, Frame.Width, Frame.Width); LottieView.AddSubview(lottie); lottie.Frame = LottieView.Bounds; lottie.SetFillXContraintTo(LottieView); lottie.LoopAnimation = true; lottie.Play(); }
public static void LoadingInChat(UIView view, bool shouldAnimate) { if (shouldAnimate) { _lottieAnimation = LOTAnimationView.AnimationNamed("progress_refresh"); var size = _mainViewSize / 4 + 8; _lottieAnimation.Frame = new CGRect(size, view.Frame.Height - 2.7f, _mainViewSize - size * 2, 2.5f); _lottieAnimation.Layer.CornerRadius = 0.8f; view.AddSubview(_lottieAnimation); _lottieAnimation.LoopAnimation = true; _lottieAnimation.ContentMode = UIViewContentMode.Redraw; _lottieAnimation.Hidden = false; _lottieAnimation.AnimationProgress = 0; _lottieAnimation.Play(); } else { if (_lottieAnimation != null) { _lottieAnimation.Hidden = true; _lottieAnimation.Pause(); _lottieAnimation?.Dispose(); _lottieAnimation = null; } } }
public override void ViewDidLoad() { base.ViewDidLoad(); LOTAnimationView animation = LOTAnimationView.AnimationNamed("heart"); View.AddSubview(animation); animation.Play(); }
public void Update(AnimatedVisualPlayer player) { if (_animation == null) { _animation = new LOTAnimationView(); SetProperties(); #if __IOS__ player.Add(_animation); #else player.AddSubview(_animation); #endif } else { SetProperties(); } void SetProperties() { var path = UriSource?.PathAndQuery ?? ""; if (_lastPath != path) { _animation.SetAnimationNamed(path); _lastPath = path; } switch (player.Stretch) { case Windows.UI.Xaml.Media.Stretch.None: _animation.ContentMode = _ViewContentMode.Center; break; case Windows.UI.Xaml.Media.Stretch.Uniform: _animation.ContentMode = _ViewContentMode.ScaleAspectFit; break; case Windows.UI.Xaml.Media.Stretch.Fill: _animation.ContentMode = _ViewContentMode.ScaleToFill; break; case Windows.UI.Xaml.Media.Stretch.UniformToFill: _animation.ContentMode = _ViewContentMode.ScaleAspectFill; break; } _animation.AnimationSpeed = (nfloat)player.PlaybackRate; if (player.AutoPlay && !_isPlaying) { Play(true); } } _player = player; }
private void AddAnimationView() { if (!animationAdded) { var loadingAnimation = LOTAnimationView.AnimationNamed("truckAnimation"); loadingAnimation.Play(); this.AddSubview(loadingAnimation); } }
private void LoadAnimationNamed(string named) { this.laAnimation.RemoveFromSuperview(); this.laAnimation = null; this.ResetAllButtons(); this.laAnimation = LOTAnimationView.AnimationNamed(named); this.laAnimation.ContentMode = UIViewContentMode.ScaleAspectFit; this.View.AddSubview(this.laAnimation); this.View.SetNeedsLayout(); }
private void LoadAnimationFromUrl(string url) { this.laAnimation.RemoveFromSuperview(); this.laAnimation = null; this.ResetAllButtons(); this.laAnimation = new LOTAnimationView(new Foundation.NSUrl(url)); this.laAnimation.ContentMode = UIViewContentMode.ScaleAspectFit; this.View.AddSubview(laAnimation); this.View.SetNeedsLayout(); }
void setupWolf() { var url = NSUrl.FromFilename("shy_wolf.json"); this.WolfAnimation = new LOTAnimationView(url); this.WolfAnimation.ContentMode = UIViewContentMode.ScaleAspectFill | UIViewContentMode.Center; var frame = this.WolfVIew.Frame; this.WolfAnimation.Frame = new CoreGraphics.CGRect(0, 0, frame.Width, frame.Height); this.WolfVIew.AddSubview(this.WolfAnimation); }
public override void ViewDidLoad() { base.ViewDidLoad(); var viewAnimation = LOTAnimationView.AnimationNamed("Logo"); View.AddSubview(viewAnimation); viewAnimation.PlayWithCompletion((finished) => { UIApplication.SharedApplication.Delegate.FinishedLaunching(UIApplication.SharedApplication, new Foundation.NSDictionary()); }); }
public LoadingOverlay(CGRect frame, string text = "") : base(frame) { BackgroundColor = UIColor.FromWhiteAlpha(0, 0.2f); _animation = LOTAnimationView.AnimationNamed("Animations/preloader"); _animation.ContentMode = UIViewContentMode.ScaleAspectFit; _animation.Frame = frame; _animation.LoopAnimation = true; _animation.Play(); Alpha = 0.75f; Add(_animation); Frame = frame; AutoresizingMask = UIViewAutoresizing.All; //nfloat labelHeight = 22; //nfloat labelWidth = Frame.Width - 20; //// derive the center x and y //nfloat centerX = Frame.Width / 2; //nfloat centerY = Frame.Height / 2; // create the activity spinner, center it horizontall and put it 5 points above center x //activitySpinner = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); //activitySpinner.Color = ConstantsiOS.GeneralRedColor; //activitySpinner.Frame = new CGRect( // centerX - (activitySpinner.Frame.Width / 2), // centerY - activitySpinner.Frame.Height - 20, // activitySpinner.Frame.Width, // activitySpinner.Frame.Height); //activitySpinner.AutoresizingMask = UIViewAutoresizing.All; //AddSubview(activitySpinner); //activitySpinner.StartAnimating(); //// create and configure the "Loading Data" label //loadingLabel = new UILabel(new CGRect( // centerX - (labelWidth / 2), // centerY + 20, // labelWidth, // labelHeight // )); //loadingLabel.BackgroundColor = UIColor.Clear; ////loadingLabel.TextColor = ConstantsiOS.LabelDarkGrayColor; //if (!string.IsNullOrEmpty(text)) // loadingLabel.Text = text; //else //{ // loadingLabel.Text = "Loading"; //TranslationExtension.LanguageBundle.LocalizedString("Mobile_Loading", ""); //} //loadingLabel.TextAlignment = UITextAlignment.Center; //loadingLabel.AutoresizingMask = UIViewAutoresizing.All; //AddSubview(loadingLabel); }
void setupRadioButton() { this.RadioButton.TouchUpInside += (sender, e) => RadioClicked(); var url = NSUrl.FromFilename("check.json"); this.RadioAnimation = new LOTAnimationView(url); this.RadioAnimation.ContentMode = UIViewContentMode.ScaleAspectFit | UIViewContentMode.Center; var frame = this.RadioContainer.Frame; this.RadioAnimation.Frame = new CoreGraphics.CGRect(0, 0, frame.Width, frame.Height); this.RadioContainer.AddSubview(this.RadioAnimation); this.RadioContainer.BringSubviewToFront(this.RadioButton); }
public override void ViewDidLoad() { base.ViewDidLoad(); var viewAnimation = LOTAnimationView.AnimationNamed("ironman"); var boundSize = UIScreen.MainScreen.Bounds.Size; viewAnimation.Frame = new CGRect(x: 0, y: 0, width: boundSize.Width, height: boundSize.Height); viewAnimation.ContentMode = UIViewContentMode.ScaleAspectFit; View.AddSubview(viewAnimation); viewAnimation.PlayWithCompletion((finished) => { UIApplication.SharedApplication.Delegate.FinishedLaunching(UIApplication.SharedApplication, new Foundation.NSDictionary()); }); }