예제 #1
0
        /// <summary>
        /// Creates a new gradient layer and inserts it as a subview if a gradient layer doesn't already exist.
        /// If one does exist, the existing one is updated.
        /// </summary>
        /// <param name="view">The native view the gradient fill is being applied to</param>
        /// <param name="gradient">The <see cref="T:XFGloss.Gradient"/> instance to copy the fill parameters from</param>
        static public void CreateGradientLayer(UIView view, Gradient gradient)
        {
            // Clear any previously-assigned background color
            view.BackgroundColor = UIColor.Clear;

            XFGlossGradientLayer gradientLayer = GetGradientLayer(view);
            // Create or update the layer as needed if a new gradient was passed to us
            bool insertLayer = false;

            if (gradientLayer == null)
            {
                gradientLayer = new XFGlossGradientLayer(view, gradient);
                insertLayer   = true;
            }
            else
            {
                gradientLayer.GradientSource = gradient;
            }

            // Insert the layer if we created a new one
            if (insertLayer)
            {
                view.Layer.InsertSublayer(gradientLayer, 0);
            }
        }
예제 #2
0
        /// <summary>
        /// Dispose any created resources and prepare the instance for garbage collection
        /// </summary>
        /// <param name="disposing">If set to <c>true</c>, dispose any created resources</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                XFGlossGradientLayer.RemoveGradientLayer(this);
            }

            base.Dispose(disposing);
        }
예제 #3
0
        /// <summary>
        /// UIView override to update our gradient layer's size to match our view's bounds whenever the bounds are
        /// changing
        /// </summary>
        public override void LayoutSubviews()
        {
            var layer = XFGlossGradientLayer.GetGradientLayer(this);

            if (layer != null)
            {
                layer.Frame = new CGRect(CGPoint.Empty, Frame.Size);
            }

            base.LayoutSubviews();
        }
예제 #4
0
        /// <summary>
        /// Updates the associated <see cref="T:XFGloss.iOS.Views.XFGlossGradientLayer"/> instance's steps collection.
        /// </summary>
        /// <param name="steps">The steps collection to assign</param>
        public void UpdateSteps(GradientStepCollection steps)
        {
            var layer = XFGlossGradientLayer.GetGradientLayer(this);

            layer?.UpdateSteps(steps);
        }
예제 #5
0
        /// <summary>
        /// Updates the associated <see cref="T:XFGloss.iOS.Views.XFGlossGradientLayer"/> instance's rotation value.
        /// </summary>
        /// <param name="rotation">An integer number between 0 and 359</param>
        public void UpdateRotation(int rotation)
        {
            var layer = XFGlossGradientLayer.GetGradientLayer(this);

            layer?.UpdateRotation(rotation);
        }
예제 #6
0
 /// <summary>
 /// Initializes a new instance of the <see cref="T:XFGloss.iOS.Views.UIBackgroundGradientView"/> class.
 /// </summary>
 /// <param name="rect">Rect.</param>
 /// <param name="gradientSource">Gradient source.</param>
 public UIBackgroundGradientView(CGRect rect, Gradient gradientSource) : base(rect)
 {
     XFGlossGradientLayer.CreateGradientLayer(this, gradientSource);
 }