Ejemplo n.º 1
0
        public static CABasicAnimation Translate(CGSize translation, double?duration = null)
        {
            var animation = CABasicAnimation.FromKeyPath("transform.translation");

            animation.To = NSValue.FromCGSize(translation);

            animation.FillMode            = Convert.MaterialAnimationFillModeToValue(MaterialAnimationFillMode.Forwards);
            animation.RemovedOnCompletion = false;
            animation.TimingFunction      = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseInEaseOut);
            if (duration != null)
            {
                animation.Duration = duration.Value;
            }
            return(animation);
        }
        public void CreateResultPositionAndSizeAnimation(UITextField resultValue, string animationPositionKey = "position", string animationSizeKey1 = "bounds.size")
        {
            //CABasicAnimation theAnimation = new CABasicAnimation();
            CABasicAnimation[] theAnimation = new CABasicAnimation[2];

            var position = new CABasicAnimation();

            position.KeyPath = animationPositionKey;
            position.SetFrom(NSValue.FromCGPoint(new CGPoint(182, 342)));
            position.SetTo(NSValue.FromCGPoint(new CGPoint(182, 400)));
            position.Duration         = 1.0;
            position.BeginTime        = 0.1;
            position.AutoReverses     = true;
            resultValue.TextColor     = UIColor.White;
            resultValue.TextAlignment = UITextAlignment.Center;
            theAnimation.Append(position);
            //resultValue.Layer.AddAnimation(position, animationPositionKey);

            CABasicAnimation heightAnimation = new CABasicAnimation();

            heightAnimation.KeyPath      = animationSizeKey1;
            heightAnimation.AutoReverses = true;
            heightAnimation.SetFrom(NSValue.FromCGSize(new CGSize(97, 30)));
            heightAnimation.SetTo(NSValue.FromCGSize(new CGSize(97, 80)));
            heightAnimation.Duration  = 10.0;
            resultValue.TextColor     = UIColor.Red;
            resultValue.TextAlignment = UITextAlignment.Center;
            heightAnimation.BeginTime = 5.0;
            theAnimation.Append(heightAnimation);
            //resultValue.Layer.AddAnimation(heightAnimation, animationSizeKey1);

            CAAnimationGroup group = new CAAnimationGroup();

            group.Duration   = 10.0;
            group.Animations = theAnimation;
            resultValue.Layer.AddAnimation(group, null);
        }