Пример #1
0
        /// <summary>
        /// Close the Modal Window and removes it from Super View
        /// </summary>
        public void Close()
        {
            NSNotificationCenter.DefaultCenter.RemoveObserver(this, "UIDeviceOrientationDidChangeNotification", null);
            CATransform3D currentTransform = this.dialogView.Layer.Transform;

            nfloat        startRotation = nfloat.Parse(this.ValueForKeyPath(new NSString("layer.transform.rotation.z")).ToString());
            CATransform3D rotation      = CATransform3D.MakeRotation((nfloat)(-startRotation + Math.PI * 270 / 180), 0, 0, 0);

            CATransform3D scale = CATransform3D.MakeScale((nfloat)1, (nfloat)1, 1);

            this.dialogView.Layer.Transform = currentTransform.Concat(scale);
            this.dialogView.Layer.Opacity   = 1;

            UIView.Animate(0.2, 0, UIViewAnimationOptions.TransitionNone, () =>
            {
                this.BackgroundColor            = UIColor.FromRGBA(0, 0, 0, 0);
                this.dialogView.Layer.Transform = currentTransform.Concat(CATransform3D.MakeScale((nfloat)0.6, (nfloat)0.6, 1));
                this.dialogView.Layer.Opacity   = 0;
            }, () =>
            {
                foreach (UIView v in this.Subviews)
                {
                    v.RemoveFromSuperview();
                }

                this.RemoveFromSuperview();
                this.SetupViews();
            });
        }
        private CATransform3D CATransform3DMakePerspective(CGPoint center, float disZ)
        {
            CATransform3D transToCenter = CATransform3D.MakeTranslation(-center.X, -center.Y, 0);
            CATransform3D transBack     = CATransform3D.MakeTranslation(center.X, center.Y, 0);
            CATransform3D scale         = CATransform3D.Identity;

            scale.m34 = -1.0f / disZ;

            return(transToCenter.Concat(scale).Concat(transBack));
        }
Пример #3
0
            void ApplyMaskScale(float scale)
            {
                // ultimately this scales the layer from the center out (rather than top/left)

                // create a transform that translates the layer by half its width/height
                // and then scales it
                CATransform3D translateScale = new CATransform3D();

                translateScale = CATransform3D.Identity;
                translateScale = translateScale.Scale(scale);
                translateScale = translateScale.Translate(-(Label.Layer.Mask.Bounds.Width / 2), -(Label.Layer.Mask.Bounds.Height / 2), 0);

                // now apply a transform that puts it back by its width/height, effectively re-centering it.
                CATransform3D postScale = new CATransform3D();

                postScale = CATransform3D.Identity;
                postScale = postScale.Translate((Label.Layer.Mask.Bounds.Width / 2), (Label.Layer.Mask.Bounds.Height / 2), 0);

                // and now concat the post scale and apply
                Label.Layer.Mask.Transform = translateScale.Concat(postScale);
            }
Пример #4
0
        public void Close()
        {
            var ea = new CustomIOSAlertViewClosingEventArgs();

            Closing?.Invoke(this, ea);
            if (ea.Cancel)
            {
                return;
            }
            CATransform3D currentTransform = DialogView.Layer.Transform;

            if (NSFoundationVersionNumber <= NSFoundationVersionNumber_iOS_7_1)
            {
                float         startRotation = ((NSNumber)DialogView.ValueForKeyPath(new NSString("layer.transform.rotation.z"))).FloatValue;
                CATransform3D rotation      = CATransform3D.MakeRotation(new nfloat(-startRotation + Math.PI * 270.0 / 180.0), 0.0f, 0.0f, 0.0f);

                DialogView.Layer.Transform = rotation.Concat(CATransform3D.MakeScale(1, 1, 1));
            }

            DialogView.Layer.Opacity = 1.0f;

            UIView.Animate(0.2f, 0.0, UIViewAnimationOptions.TransitionNone, () =>
            {
                BackgroundColor            = UIColor.FromRGBA(0.0f, 0.0f, 0.0f, 0.0f);
                DialogView.Layer.Transform = currentTransform.Concat(CATransform3D.MakeScale(0.6f, 0.6f, 1.0f));
                DialogView.Layer.Opacity   = 0;
            }, () =>
            {
                foreach (var v in Subviews)
                {
                    v.RemoveFromSuperview();
                }
                RemoveFromSuperview();

                Closed?.Invoke(this, EventArgs.Empty);
            });
        }
Пример #5
0
 internal static CATransform3D Prepend(this CATransform3D a, CATransform3D b) =>
 b.Concat(a);
 private CATransform3D CATransform3DPerspect(CATransform3D t, CGPoint center, float disZ)
 {
     return(t.Concat(CATransform3DMakePerspective(center, disZ)));
 }
Пример #7
0
 public static CATransform3D Prepend(this CATransform3D a, CATransform3D b) =>
 b.Concat(a);