Beispiel #1
0
        CALayer SetupBackgroundLayer()
        {
            backgroundLayer = new CAGradientLayer();

            CGColor gradColor1 = new CGColor(13.0f / 255.0f, 116.0f / 255.0f, 1.0f, 1.0f);
            CGColor gradColor2 = new CGColor(0.0f, 53.0f / 255.0f, 126.0f / 255.0f, 1.0f);

            ((CAGradientLayer)backgroundLayer).Colors = new CGColor[2] {
                gradColor1, gradColor2
            };
            backgroundLayer.CornerRadius = 12.0f;
            CAConstraintLayoutManager layout = CAConstraintLayoutManager.LayoutManager;

            backgroundLayer.LayoutManager = layout;

            return(backgroundLayer);
        }
        ClockLayer SetupBackgroundLayer()
        {
            // Create the color animation
            var rg = CABasicAnimation.FromKeyPath("clockColor");

            rg.Duration = 3;
            rg.From     = new NSObject(red.Handle);
            rg.To       = new NSObject(green.Handle);

            var gb = CABasicAnimation.FromKeyPath("clockColor");

            gb.Duration  = 3;
            gb.BeginTime = 3;
            gb.From      = rg.To;
            gb.To        = new NSObject(blue.Handle);

            var br = CABasicAnimation.FromKeyPath("clockColor");

            br.Duration  = 3;
            br.BeginTime = 6;
            br.From      = gb.To;
            br.To        = rg.From;

            backgroundAnimation             = new CAAnimationGroup();
            backgroundAnimation.RepeatCount = 1000;
            backgroundAnimation.Duration    = 9;
            backgroundAnimation.Animations  = new CAAnimation [] { rg, gb, br };

            // Create the background layer
            backgroundLayer            = new ClockLayer();
            backgroundLayer.ClockColor = new CGColor(0.5f, 1f, 0f, 1.0f);
            backgroundLayer.AddAnimation(backgroundAnimation, "colorAnimation");

            CAConstraintLayoutManager layout = CAConstraintLayoutManager.LayoutManager;

            backgroundLayer.LayoutManager = layout;

            return(backgroundLayer);
        }