コード例 #1
0
        public void LayersToCenter(AnimationPacket _animatePacket)
        {
            CABasicAnimation _aniLayersToCenter;
            AnimateDelegate  _myAnimateDelegate = new AnimateDelegate();

            var pt = _animatePacket.Layer1.Position;

            _animatePacket.Layer1.Position = _animatePacket.ToPosition1;
            _animatePacket.Layer2.Position = _animatePacket.ToPosition1;

            // ** Position Animation
            _aniLayersToCenter = CABasicAnimation.FromKeyPath("position");
            // ** These two set if the presentation layer will stay set in the final animated position
            _aniLayersToCenter.RemovedOnCompletion = true;
            //_aniLayersToCenter.FillMode = CAFillMode.Forwards;
            _aniLayersToCenter.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear);

            _aniLayersToCenter.Delegate = _myAnimateDelegate;
            _aniLayersToCenter.From     = NSValue.FromCGPoint(pt);
            _aniLayersToCenter.To       = NSValue.FromCGPoint(_animatePacket.ToPosition1);
            _aniLayersToCenter.Duration = 0.5f;



            _animatePacket.Layer1.AddAnimation(_aniLayersToCenter, "position");
            _animatePacket.Layer2.AddAnimation(_aniLayersToCenter, "position");
        }
コード例 #2
0
        public void LayersToEdge(AnimationPacket _animatePacket)
        {
            CABasicAnimation _aniLayersToEdge;
            CABasicAnimation _aniLayersToEdgeFade;
            CAAnimationGroup _animationGroup = new CAAnimationGroup();

            AnimateDelegate _myAnimateDelegate = new AnimateDelegate();

            var     pt = _animatePacket.Layer1.Position;
            CGPoint x;

            if (_animatePacket.DirectionY == G__NumberDisplayPositionY.Top)
            {
                _animatePacket.Layer1.Position = _animatePacket.ToPosition1;
                _animatePacket.Layer2.Position = _animatePacket.ToPosition1;
                x = _animatePacket.ToPosition1;
            }
            else
            {
                _animatePacket.Layer1.Position = _animatePacket.ToPosition2;
                _animatePacket.Layer2.Position = _animatePacket.ToPosition2;
                x = _animatePacket.ToPosition2;
            }

            _aniLayersToEdge = CABasicAnimation.FromKeyPath("position");
            // ** These two set if the presentation layer will stay set in the final animated position
            _aniLayersToEdge.RemovedOnCompletion = true;
            _aniLayersToEdge.FillMode            = CAFillMode.Forwards;
            _aniLayersToEdge.TimingFunction      = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear);
            _aniLayersToEdge.Delegate            = _myAnimateDelegate;
            _aniLayersToEdge.From = NSValue.FromCGPoint(pt);
            _aniLayersToEdge.To   = NSValue.FromCGPoint(x);
            //_aniLayersToEdge.Duration = 1.0f;
            //_aniLayersToEdge.RepeatCount = 1.0f;

            // ** Fade Animation
            _aniLayersToEdgeFade = CABasicAnimation.FromKeyPath("opacity");
            // ** These two set if the presentation layer will stay set in the final animated position
            _aniLayersToEdgeFade.RemovedOnCompletion = true;
            _aniLayersToEdgeFade.FillMode            = CAFillMode.Forwards;
            _aniLayersToEdgeFade.TimingFunction      = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Linear);
            _aniLayersToEdgeFade.Delegate            = _myAnimateDelegate;
            _aniLayersToEdgeFade.From = NSNumber.FromFloat(1.0f);
            _aniLayersToEdgeFade.To   = NSNumber.FromFloat(0.0f);
            //_aniLayersToCenter.Duration = 1.0f;

            var y = NWAnimations.SpinLogo();

            _animationGroup.Duration   = 0.5f;
            _animationGroup.Animations = new CAAnimation[] { _aniLayersToEdgeFade, _aniLayersToEdge, y };
            _animatePacket.Layer1.AddAnimation(_animationGroup, null);
            _animatePacket.Layer2.AddAnimation(_animationGroup, null);
        }