Пример #1
0
        /* Dialog close animation then cleaning and removing the view from the parent */
        private void Close()
        {
            var currentTransform = _dialogView.Layer.Transform;

            if (ValueForKeyPath(new NSString(str: "layer.transform.rotation.z")) is NSNumber startRotation)
            {
                var startRotationAngle = startRotation.DoubleValue;

                var rotation = CATransform3D.MakeRotation(
                    (nfloat)(-startRotationAngle + Math.PI * 270 / 180d),
                    x: 0f,
                    y: 0f,
                    z: 0f);

                _dialogView.Layer.Transform = rotation.Concat(CATransform3D.MakeScale(sx: 1, sy: 1, sz: 1));
            }

            _dialogView.Layer.Opacity = 1;

            Animate(
                duration: 0.2,
                delay: 0d,
                UIViewAnimationOptions.TransitionNone,
                animation: () =>
            {
                BackgroundColor = UIColor.FromRGBA(
                    red: 0,
                    green: 0,
                    blue: 0,
                    alpha: 0);

                _dialogView.Layer.Transform = currentTransform.Concat(CATransform3D.MakeScale(sx: 0.6f, sy: 0.6f, sz: 1f));
                _dialogView.Layer.Opacity   = 0;
            },
                completion: () =>
            {
                var subViews = Subviews.ToArray();

                foreach (var v in subViews)
                {
                    v.RemoveFromSuperview();
                }
            });

            RemoveFromSuperview();
        }
Пример #2
0
        private void Initialize()
        {
            UserInteractionEnabled = true;
            ClipsToBounds          = true;

            Layer.BorderWidth = 1;
            Layer.BorderColor = UIColor.LightGray.CGColor;

            _title      = new UILabel();
            _title.Font = UIFont.BoldSystemFontOfSize(20);
            _title.Text = _searchResult.Article.Title;
            Add(_title);

            foreach (var searchResultFinding in _searchResult.Findings.Take(5).ToArray())
            {
                var part = new ArticlePartView(searchResultFinding.Normalize());
                Add(part);
            }

            Layout = () =>
            {
                _title.SetSizeThatFits(Frame.Width);
                _title.ChangePosition(0, 0);

                var y = _title.Frame.Bottom;

                foreach (var subview in Subviews.ToArray().Where(x => x is ArticlePartView).Cast <ArticlePartView>())
                {
                    subview.SetSizeThatFits(Frame.Width);
                    subview.ChangeX(0);
                    subview.ChangeY(y);

                    y = subview.Frame.Bottom + 5;
                }
            };

            Layout();

            TouchUpInside += OnTouchUpInside;
        }