Exemple #1
0
        protected override void OnDetached()
        {
            touchEvents.TouchBegin  -= OnTouchBegin;
            touchEvents.TouchEnd    -= OnTouchEnd;
            touchEvents.TouchCancel -= OnTouchEnd;

            view.RemoveGestureRecognizer(touchRecognizer);
            touchRecognizer.Delegate?.Dispose();
            touchRecognizer.Delegate = null;
            touchRecognizer.Dispose();

            touchEvents     = null;
            touchRecognizer = null;

            layer.RemoveFromSuperview();
            layer.Dispose();
            layer = null;

            view = null;
        }
Exemple #2
0
        protected override void OnAttached()
        {
            view = Control ?? Container;

            view.UserInteractionEnabled = true;

            layer = new UIView
            {
                Alpha  = 0,
                Opaque = false,
                UserInteractionEnabled = false
            };
            view.AddSubview(layer);

            layer.TranslatesAutoresizingMaskIntoConstraints = false;

            layer.TopAnchor.ConstraintEqualTo(view.TopAnchor).Active       = true;
            layer.LeftAnchor.ConstraintEqualTo(view.LeftAnchor).Active     = true;
            layer.BottomAnchor.ConstraintEqualTo(view.BottomAnchor).Active = true;
            layer.RightAnchor.ConstraintEqualTo(view.RightAnchor).Active   = true;

            view.BringSubviewToFront(layer);

            touchEvents = new TouchEvents();

            touchRecognizer          = new TouchEventsGestureRecognizer(touchEvents);
            touchRecognizer.Delegate = new ShouldRecognizeSimultaneouslyRecognizerDelegate();

            view.AddGestureRecognizer(touchRecognizer);

            touchEvents.TouchBegin  += OnTouchBegin;
            touchEvents.TouchEnd    += OnTouchEnd;
            touchEvents.TouchCancel += OnTouchEnd;

            UpdateEffectColor();
        }
 public TouchEventsGestureRecognizer(TouchEvents events) => this.events = events;