Exemplo n.º 1
0
        void updateImage()
        {
            UIImage effectImage = null;

            effectImage = image.ApplyLightEffect();
            loginBackgroundImage.Image = effectImage;
        }
Exemplo n.º 2
0
        partial void Update(UITapGestureRecognizer sender)
        {
            UIImage effectImage = null;
            var     effectText  = string.Empty;
            var     effectColor = UIColor.White;

            switch (currentEffect)
            {
            case EffectType.None:
                currentEffect = EffectType.Light;

                effectImage = image.ApplyLightEffect();
                effectText  = "Light";
                break;

            case EffectType.Light:
                currentEffect = EffectType.ExtraLight;

                effectImage = image.ApplyExtraLightEffect();
                effectText  = "Extra Light";
                effectColor = UIColor.LightGray;
                break;

            case EffectType.ExtraLight:
                currentEffect = EffectType.Dark;

                effectImage = image.ApplyDarkEffect();
                effectText  = "Dark";
                effectColor = UIColor.DarkGray;
                break;

            case EffectType.Dark:
                currentEffect = EffectType.ColorTint;

                effectImage = image.ApplyTintEffect(UIColor.Blue);
                effectText  = "Color tint";
                effectColor = UIColor.DarkGray;
                break;

            case EffectType.ColorTint:
                currentEffect = EffectType.None;

                effectImage = image;
                break;
            }

            imageView.Image       = effectImage;
            effectLabel.Text      = effectText;
            effectLabel.TextColor = effectColor;
        }
Exemplo n.º 3
0
        void UpdateImage(UITapGestureRecognizer recognizer)
        {
            if (imageIndex > 4)
            {
                imageIndex = 0;
            }

            string  effectText  = "";
            UIImage effectImage = null;

            switch (imageIndex)
            {
            case 0:
                effectImage = image;
                break;

            case 1:
                effectImage           = image.ApplyLightEffect();
                effectText            = "Light";
                effectLabel.TextColor = UIColor.White;
                break;

            case 2:
                effectImage           = image.ApplyExtraLightEffect();
                effectText            = "Extra Light";
                effectLabel.TextColor = UIColor.LightGray;
                break;

            case 3:
                effectImage           = image.ApplyDarkEffect();
                effectText            = "Dark";
                effectLabel.TextColor = UIColor.DarkGray;
                break;

            case 4:
                effectImage           = image.ApplyTintEffect(UIColor.Blue);
                effectText            = "Color tint";
                effectLabel.TextColor = UIColor.DarkGray;
                break;

            default:
                break;
            }

            imageView.Image  = effectImage;
            effectLabel.Text = effectText;

            imageIndex++;
        }
Exemplo n.º 4
0
        void ApplyBackgroundToView(UIButton button, UIView backgroundView)
        {
            // This makes sure we have the coordinates relative to the backgroundView. Without this, the image drawn
            // for the button would be at the incorrect place of the background.
            RectangleF buttonRectInBGViewCoords = button.ConvertRectToView(button.Bounds, backgroundView);

            UIGraphics.BeginImageContextWithOptions(button.Frame.Size, false, window.Screen.Scale);

            // Make a new image of the backgroundView (basically a screenshot of the view)
            backgroundView.DrawViewHierarchy(new RectangleF(-buttonRectInBGViewCoords.X, -buttonRectInBGViewCoords.Y,
                                                            backgroundView.Frame.Width, backgroundView.Frame.Height), true);
            UIImage newBGImage = UIGraphics.GetImageFromCurrentImageContext();

            UIGraphics.EndImageContext();

            // Apply the blur effect
            newBGImage = newBGImage.ApplyLightEffect();

            // Set the blurred image as the background for the button
            button.SetBackgroundImage(newBGImage, UIControlState.Normal);
            button.Layer.CornerRadius  = 4.0f;
            button.Layer.MasksToBounds = true;
        }