예제 #1
0
 public void StopLoading()
 {
     _lottieAnimation?.Pause();
     _lottieAnimation?.RemoveFromSuperview();
     _lottieAnimation?.Dispose();
     _lottieAnimation = null;
 }
        private void InitAnimationView()
        {
            if (_loadingAnimationView != null)
            {
                _loadingAnimationView.RemoveFromSuperview();
            }

            _loadingAnimationView = LOTAnimationView.AnimationNamed("lottie_pull_to_refresh");
            _loadingAnimationView.ClipsToBounds  = true;
            _loadingAnimationView.AnimationSpeed = 3.0f;
            _loadingAnimationView.ContentMode    = UIViewContentMode.ScaleAspectFill;
            _loadingAnimationView.LoopAnimation  = true;
            _loadingAnimationView.TranslatesAutoresizingMaskIntoConstraints = false;
            this.AddSubview(_loadingAnimationView);
            var animationCenterX = NSLayoutConstraint.Create(_loadingAnimationView, NSLayoutAttribute.CenterX, NSLayoutRelation.Equal, this, NSLayoutAttribute.CenterX, 1f, 0f);
            //var animationCenterY = NSLayoutConstraint.Create(_loadingAnimationView, NSLayoutAttribute.CenterY, NSLayoutRelation.Equal, refreshControl, NSLayoutAttribute.CenterY, 1f, 0f);
            var animationWidth  = NSLayoutConstraint.Create(_loadingAnimationView, NSLayoutAttribute.Width, NSLayoutRelation.Equal, this, NSLayoutAttribute.Width, 0.3f, 0f);
            var animationHeight = NSLayoutConstraint.Create(_loadingAnimationView, NSLayoutAttribute.Height, NSLayoutRelation.Equal, this, NSLayoutAttribute.Height, 1f, 0f);

            this.AddConstraint(animationCenterX);
            //this.AddConstraint(animationCenterY);
            this.AddConstraint(animationWidth);
            this.AddConstraint(animationHeight);
        }