Exemple #1
0
        // lack of generated delegate force us to add events manually too

        _CAAnimationDelegate EnsureCAAnimationDelegate()
        {
            var del = Delegate;

            if (del == null || (!(del is _CAAnimationDelegate)))
            {
                del      = new _CAAnimationDelegate();
                Delegate = del;
            }
            return((_CAAnimationDelegate)del);
        }
Exemple #2
0
        public void CreateBarAnimationForHeight(CALayer layer, float toValue, CAAnimationDelegate @delegate)
        {
            const string key        = "bounds.size.height";
            var          _fromValue = layer.ValueForKeyPath(new NSString(key));
            var          _toValue   = new NSNumber(toValue);
            var          _key       = new NSString(key);

            var barAnimation = CABasicAnimation.FromKeyPath(key);
            var currentValue = _fromValue;

            if (layer.PresentationLayer != null)
            {
                currentValue = layer.PresentationLayer.ValueForKeyPath(_key);
            }
            barAnimation.From           = currentValue;
            barAnimation.To             = _toValue;
            barAnimation.Delegate       = @delegate;
            barAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Default);
            layer.AddAnimation(barAnimation, key);
            layer.SetValueForKeyPath(_toValue, _key);
        }
        public void CreateArcAnimationForKey (string key, double fromValue, double toValue, CAAnimationDelegate @delegate)
        {
            var _fromValue = new NSNumber (fromValue);
            var _toValue = new NSNumber (toValue);
            var _key = new NSString (key);

            var arcAnimation = CABasicAnimation.FromKeyPath (key);
            var currentAngle = _fromValue;
            if (PresentationLayer != null) {
                currentAngle = (NSNumber)PresentationLayer.ValueForKey (_key);
            }
            arcAnimation.Duration = 1.0f;
            arcAnimation.From = currentAngle;
            arcAnimation.To = _toValue;
            arcAnimation.Delegate = @delegate;
            arcAnimation.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.Default);
            AddAnimation (arcAnimation, key);
            SetValueForKey (_toValue, _key);
        }
Exemple #4
0
        public void CreateArcAnimationForKey(string key, double fromValue, double toValue, CAAnimationDelegate @delegate)
        {
            var _fromValue = new NSNumber(fromValue);
            var _toValue   = new NSNumber(toValue);
            var _key       = new NSString(key);

            var arcAnimation = CABasicAnimation.FromKeyPath(key);
            var currentAngle = _fromValue;

            if (PresentationLayer != null)
            {
                currentAngle = (NSNumber)PresentationLayer.ValueForKey(_key);
            }
            arcAnimation.Duration       = 1.0f;
            arcAnimation.From           = currentAngle;
            arcAnimation.To             = _toValue;
            arcAnimation.Delegate       = @delegate;
            arcAnimation.TimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.Default);
            AddAnimation(arcAnimation, key);
            SetValueForKey(_toValue, _key);
        }
Exemple #5
0
        public void CreateBarAnimationForHeight ( CALayer layer, nfloat toValue, CAAnimationDelegate @delegate)
        {
            const string key = "bounds.size.height";
            var _fromValue =  layer.ValueForKeyPath ( new NSString ( key));
            var _toValue = new NSNumber (toValue);
            var _key = new NSString (key);

            var barAnimation = CABasicAnimation.FromKeyPath (key);
            var currentValue = _fromValue;
            if (layer.PresentationLayer != null) {
                currentValue = layer.PresentationLayer.ValueForKeyPath (_key);
            }
            barAnimation.From = currentValue;
            barAnimation.To = _toValue;
            barAnimation.Delegate = @delegate;
            barAnimation.TimingFunction = CAMediaTimingFunction.FromName (CAMediaTimingFunction.Default);
            layer.AddAnimation (barAnimation, key);
            layer.SetValueForKeyPath (_toValue, _key);
        }