コード例 #1
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            var cell = tv.DequeueReusableCell(Key);

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, Key);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
                cell.Frame          = new RectangleF(cell.Frame.X, cell.Frame.Y, tv.Frame.Width, cell.Frame.Height);
            }
            else
            {
                RemoveTag(cell, 1);
            }

            if (button == null)
            {
                RectangleF frame = cell.Frame;
                // after the first run the Y offset of the cell is unknown,
                frame.Y = 0;
                frame.Inflate(-8, 0);

                button = new GlassButton(frame);
                button.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleBottomMargin;
                button.Font             = UIFont.BoldSystemFontOfSize(22);
                button.TouchUpInside   += (o, e) => tapped.Invoke();
            }
            else
            {
                button.RemoveFromSuperview();
            }

            button.SetTitle(this.Caption, UIControlState.Normal);
            button.SetTitleColor(UIColor.White, UIControlState.Normal);
            button.BackgroundColor  = UIColor.Clear;
            button.HighlightedColor = this.HighlightedColor;
            button.NormalColor      = this.NormalColor;
            button.DisabledColor    = this.DisabledColor;


            // note: button is a child of the sell itself instead of the content area so the borders of the button don't
            // do weird visual tricks with the borders of the table section
            cell.Add(button);

            return(cell);
        }
コード例 #2
0
        public override UITableViewCell GetCell(UITableView tv)
        {
            var cell = tv.DequeueReusableCell(Key);

            if (cell == null)
            {
                cell = new UITableViewCell(UITableViewCellStyle.Default, Key);
                cell.SelectionStyle = UITableViewCellSelectionStyle.None;
                cell.Frame          = new RectangleF(cell.Frame.X, cell.Frame.Y, tv.Frame.Width, cell.Frame.Height);
            }
            else
            {
                RemoveTag(cell, 1);
            }

            if (button == null)
            {
                RectangleF frame = cell.Frame;
                frame.Inflate(-10, 0);

                button = new GlassButton(frame);
                button.TouchUpInside += (o, e) => tapped.Invoke();
                button.Font           = UIFont.BoldSystemFontOfSize(22);
            }
            else
            {
                button.RemoveFromSuperview();
            }

            button.SetTitle(this.Caption, UIControlState.Normal);
            button.SetTitleColor(UIColor.White, UIControlState.Normal);
            button.BackgroundColor  = UIColor.Clear;
            button.HighlightedColor = this.HighlightedColor;
            button.NormalColor      = this.NormalColor;
            button.DisabledColor    = this.DisabledColor;

            cell.Add(button);

            return(cell);
        }
コード例 #3
0
        public void TransitionOutCompletion(NSAction action)
        {
            switch (this.TransitionStyle)
            {
                case SIAlertViewTransitionStyle.SlideFromBottom:
                    {
                        RectangleF rect = this._ContainerView.Frame;
                        var locationY = this.Bounds.Size.Height;
                        rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                        UIView.Animate(
                            duration: 0.3f,
                            delay: 0f,
                            options: UIViewAnimationOptions.CurveEaseIn,
                            animation: () => { this._ContainerView.Frame = rect; },
                            completion: () => { if (action != null) action.Invoke(); });
                    }
                    break;

                case SIAlertViewTransitionStyle.SlideFromTop:
                    {
                        RectangleF rect = this._ContainerView.Frame;
                        var locationY = -rect.Size.Height;
                        rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                        UIView.Animate(
                            duration: 0.3f,
                            delay: 0f,
                            options: UIViewAnimationOptions.CurveEaseIn,
                            animation: () => { this._ContainerView.Frame = rect; },
                            completion: () => { if (action != null) action.Invoke(); });
                    }
                    break;

                case SIAlertViewTransitionStyle.Fade:
                    {
                        UIView.Animate(
                            duration: 0.25f,
                            delay: 0f,
                            options: UIViewAnimationOptions.CurveEaseIn,
                            animation: () => { this._ContainerView.Alpha = 0f; },
                            completion: () => { if (action != null) action.Invoke(); });
                    }
                    break;

                //case SIAlertViewTransitionStyle,Bounce:
                //{
                //    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
                //    animation.values = @[@(1), @(1.2), @(0.01)];
                //    animation.keyTimes = @[@(0), @(0.4), @(1)];
                //    animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
                //    animation.duration = 0.35;
                //    animation.delegate = self;
                //    [animation setValue:completion forKey:@"handler"];
                //    [self.containerView.layer addAnimation:animation forKey:@"bounce"];

                //    self.containerView.transform = CGAffineTransformMakeScale(0.01, 0.01);
                //}
                //    break;

                case SIAlertViewTransitionStyle.DropDown:
                    {
                        PointF point = this._ContainerView.Center;
                        PointF newPoint = new PointF(point.X, point.Y + this.Bounds.Size.Height);
                        UIView.Animate(
                            duration: 0.3f,
                            delay: 0f,
                            options: UIViewAnimationOptions.CurveEaseIn,
                            animation: () =>
                            {
                                this._ContainerView.Center = newPoint;
                                float angle = GetRandomAngle();
                                this._ContainerView.Transform = CGAffineTransform.MakeRotation(angle);
                            },
                            completion: () => { if (action != null) action.Invoke(); });
                    }
                    break;

                default:
                    break;
            }
        }
コード例 #4
0
        private void TransitionInCompletion(NSAction action)
        {
            // convenience Func for float-to-NSNumber conversion
            Func<float, NSNumber> f = (x) => { return NSNumber.FromFloat(x); };

            Func<string, CAMediaTimingFunction> t = (s) => { return CAMediaTimingFunction.FromName(s); };

            switch (this.TransitionStyle)
            {
                case SIAlertViewTransitionStyle.SlideFromBottom:
                    {
                        RectangleF originalRect = this._ContainerView.Frame;
                        RectangleF rect = originalRect;
                        float locationY = this.Bounds.Size.Height;
                        rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                        this._ContainerView.Frame = rect;
                        UIView.Animate(
                            duration: 0.3f,
                            delay: 0f,
                            options: UIViewAnimationOptions.TransitionNone,
                            animation: () => { this._ContainerView.Frame = originalRect; },
                            completion: () => { if (action != null) action.Invoke(); });
                    }
                    break;

                case SIAlertViewTransitionStyle.SlideFromTop:
                    {
                        RectangleF rect = this._ContainerView.Frame;
                        RectangleF originalRect = rect;
                        float locationY = -rect.Size.Height;
                        rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                        this._ContainerView.Frame = rect;
                        UIView.Animate(
                            duration: 0.3f,
                            delay: 0f,
                            options: UIViewAnimationOptions.TransitionNone,
                            animation: () => { this._ContainerView.Frame = originalRect; },
                            completion: () => { if (action != null) action.Invoke(); });
                    }
                    break;

                case SIAlertViewTransitionStyle.Fade:
                    {
                        this._ContainerView.Alpha = 0f;
                        UIView.Animate(
                            duration: 0.3f,
                            delay: 0f,
                            options: UIViewAnimationOptions.TransitionNone,
                            animation: () => { this._ContainerView.Alpha = 1f; },
                            completion: () => { if (action != null) action.Invoke(); });
                    }
                    break;

                // These two remaining transition styles are not yet supported because I have not yet figured how to properly wire up the Delegate property on CAKeyFrameAnimation

                //case SIAlertViewTransitionStyle.Bounce:
                //{
                //    CAKeyFrameAnimation animation = CAKeyFrameAnimation.GetFromKeyPath(@"transform.scale");
                //    animation.Values = new NSNumber[] { f(0.01f), f(1.2f), f(0.9f), f(1f) };
                //    animation.KeyTimes = new NSNumber[] { f(0f), f(0.4f), f(0.6f), f(1f) };
                //    animation.TimingFunctions = new CAMediaTimingFunction[] { t(CAMediaTimingFunction.Linear.ToString()), t(CAMediaTimingFunction.Linear.ToString()), t(CAMediaTimingFunction.EaseOut.ToString()) };
                //    animation.Duration = 0.5f;
                //    animation.Delegate = 


                //    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
                //    animation.values = @[@(0.01), @(1.2), @(0.9), @(1)];
                //    animation.keyTimes = @[@(0), @(0.4), @(0.6), @(1)];
                //    animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
                //    animation.duration = 0.5;
                //    animation.delegate = self;
                //    [animation setValue:completion forKey:@"handler"];
                //    [self.containerView.layer addAnimation:animation forKey:@"bouce"];
                //}
                //break;

                //case SIAlertViewTransitionStyle.DropDown:
                //{
                //    CGFloat y = self.containerView.center.y;
                //    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.y"];
                //    animation.values = @[@(y - self.bounds.size.height), @(y + 20), @(y - 10), @(y)];
                //    animation.keyTimes = @[@(0), @(0.5), @(0.75), @(1)];
                //    animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
                //    animation.duration = 0.4;
                //    animation.delegate = self;
                //    [animation setValue:completion forKey:@"handler"];
                //    [self.containerView.layer addAnimation:animation forKey:@"dropdown"];
                //}
                //break;

                // for now, has the same body as the SlideFromTop case;
                case SIAlertViewTransitionStyle.DropDown:
                    {
                        RectangleF rect = this._ContainerView.Frame;
                        RectangleF originalRect = rect;
                        float locationY = -rect.Size.Height;
                        rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                        this._ContainerView.Frame = rect;
                        UIView.Animate(
                            duration: 0.3f,
                            delay: 0f,
                            options: UIViewAnimationOptions.TransitionNone,
                            animation: () => { this._ContainerView.Frame = originalRect; },
                            completion: () => { if (action != null) action.Invoke(); });
                    }
                    break;

                default:
                    break;
            }
        }
コード例 #5
0
ファイル: FlipView.cs プロジェクト: chrisbranson/FlipView
        public void Flip(FlipDirection direction, NSAction completion)
        {
            if (flippingInProgress || FrontView == null || BackView == null)
            {
                return;
            }

            flippingInProgress = true;

            projectionLayer       = CALayer.Create(); // this is to make the perspective and 2.5D effect
            projectionLayer.Frame = this.Layer.Bounds;

            var   perspective = CATransform3D.Identity;
            float zDistanse   = 350f;   // change this to the actual perspective and distance of the projection plane

            perspective.m34 = 1f / -zDistanse;
            projectionLayer.SublayerTransform = perspective;

            this.Layer.AddSublayer(projectionLayer);

            frontImage = FrontView.GetImage();
            backImage  = BackView.GetImage();

            topFaceLayer       = new GradientLayer(GradientLayerType.Face, GradientLayerAreaType.Top);
            topFaceLayer.Frame = new RectangleF(0f, 0f, projectionLayer.Frame.Size.Width, (float)Math.Floor(projectionLayer.Frame.Size.Height / 2f));

            bottomFaceLayer       = new GradientLayer(GradientLayerType.Face, GradientLayerAreaType.Bottom);
            bottomFaceLayer.Frame = new RectangleF(0f, (float)Math.Floor(projectionLayer.Frame.Size.Height / 2f), projectionLayer.Frame.Size.Width, (float)Math.Floor(projectionLayer.Frame.Size.Height / 2f));

            mainFlipLayer = new DoubleSidedLayer();

            mainFlipLayer.AnchorPoint = new PointF(1f, 1f);
            mainFlipLayer.Frame       = new RectangleF(0f, 0f, projectionLayer.Frame.Size.Width, (float)Math.Floor(projectionLayer.Frame.Size.Height / 2f));
            mainFlipLayer.ZPosition   = 1f;

            mainFlipLayer.FrontLayer = new GradientLayer(GradientLayerType.Flip, GradientLayerAreaType.Top);
            mainFlipLayer.BackLayer  = new GradientLayer(GradientLayerType.Flip, GradientLayerAreaType.Bottom);

            // offscreen rendering optimization to reuse the offscreen buffer
            topFaceLayer.ShouldRasterize    = true;
            bottomFaceLayer.ShouldRasterize = true;

            if (direction == FlipDirection.Down)
            {
                topFaceLayer.Contents             = backImage.CGImage;
                bottomFaceLayer.Contents          = frontImage.CGImage;
                mainFlipLayer.FrontLayer.Contents = frontImage.CGImage;
                mainFlipLayer.BackLayer.Contents  = backImage.CGImage;

                topFaceLayer.GradientOpacity = 1f;

                mainFlipLayer.Transform = CATransform3D.Identity;
            }
            else
            {
                topFaceLayer.Contents             = frontImage.CGImage;
                bottomFaceLayer.Contents          = backImage.CGImage;
                mainFlipLayer.FrontLayer.Contents = backImage.CGImage;
                mainFlipLayer.BackLayer.Contents  = frontImage.CGImage;

                bottomFaceLayer.GradientOpacity = 1f;

                mainFlipLayer.Transform = CATransform3D.MakeRotation((float)-Math.PI, 1f, 0f, 0f);
            }

            // Add layers to the projection layer, so we apply the projections to it
            projectionLayer.AddSublayer(topFaceLayer);
            projectionLayer.AddSublayer(bottomFaceLayer);
            projectionLayer.AddSublayer(mainFlipLayer);

            NSTimer.CreateScheduledTimer(0.01, delegate {
                CATransaction.Begin();
                CATransaction.AnimationDuration       = Duration;
                CATransaction.AnimationTimingFunction = CAMediaTimingFunction.FromName(CAMediaTimingFunction.EaseOut);
                CATransaction.CompletionBlock         = delegate {
                    fv                 = this.FrontView;
                    FrontView          = BackView;
                    BackView           = fv;
                    flippingInProgress = false;

                    if (completion != null)
                    {
                        completion.Invoke();
                    }
                };

                // this is the whole trick, change the angle in timing function
                float angle             = (float)Math.PI * (1f - (float)direction);
                mainFlipLayer.Transform = CATransform3D.MakeRotation(angle, 1f, 0f, 0f);

                topFaceLayer.GradientOpacity    = (float)direction;
                bottomFaceLayer.GradientOpacity = 1f - (float)direction;

                mainFlipLayer.FrontLayer.GradientOpacity = 1f - (float)direction;
                mainFlipLayer.BackLayer.GradientOpacity  = (float)direction;

                CATransaction.Commit();
            });
        }
コード例 #6
0
        public void TransitionOutCompletion(NSAction action)
        {
            switch (this.TransitionStyle)
            {
            case SIAlertViewTransitionStyle.SlideFromBottom:
            {
                RectangleF rect      = this._ContainerView.Frame;
                var        locationY = this.Bounds.Size.Height;
                rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                UIView.Animate(
                    duration: 0.3f,
                    delay: 0f,
                    options: UIViewAnimationOptions.CurveEaseIn,
                    animation: () => { this._ContainerView.Frame = rect; },
                    completion: () => { if (action != null)
                                        {
                                            action.Invoke();
                                        }
                    });
            }
            break;

            case SIAlertViewTransitionStyle.SlideFromTop:
            {
                RectangleF rect      = this._ContainerView.Frame;
                var        locationY = -rect.Size.Height;
                rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                UIView.Animate(
                    duration: 0.3f,
                    delay: 0f,
                    options: UIViewAnimationOptions.CurveEaseIn,
                    animation: () => { this._ContainerView.Frame = rect; },
                    completion: () => { if (action != null)
                                        {
                                            action.Invoke();
                                        }
                    });
            }
            break;

            case SIAlertViewTransitionStyle.Fade:
            {
                UIView.Animate(
                    duration: 0.25f,
                    delay: 0f,
                    options: UIViewAnimationOptions.CurveEaseIn,
                    animation: () => { this._ContainerView.Alpha = 0f; },
                    completion: () => { if (action != null)
                                        {
                                            action.Invoke();
                                        }
                    });
            }
            break;

            //case SIAlertViewTransitionStyle,Bounce:
            //{
            //    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
            //    animation.values = @[@(1), @(1.2), @(0.01)];
            //    animation.keyTimes = @[@(0), @(0.4), @(1)];
            //    animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
            //    animation.duration = 0.35;
            //    animation.delegate = self;
            //    [animation setValue:completion forKey:@"handler"];
            //    [self.containerView.layer addAnimation:animation forKey:@"bounce"];

            //    self.containerView.transform = CGAffineTransformMakeScale(0.01, 0.01);
            //}
            //    break;

            case SIAlertViewTransitionStyle.DropDown:
            {
                PointF point    = this._ContainerView.Center;
                PointF newPoint = new PointF(point.X, point.Y + this.Bounds.Size.Height);
                UIView.Animate(
                    duration: 0.3f,
                    delay: 0f,
                    options: UIViewAnimationOptions.CurveEaseIn,
                    animation: () =>
                    {
                        this._ContainerView.Center = newPoint;
                        float angle = GetRandomAngle();
                        this._ContainerView.Transform = CGAffineTransform.MakeRotation(angle);
                    },
                    completion: () => { if (action != null)
                                        {
                                            action.Invoke();
                                        }
                    });
            }
            break;

            default:
                break;
            }
        }
コード例 #7
0
        private void TransitionInCompletion(NSAction action)
        {
            // convenience Func for float-to-NSNumber conversion
            Func <float, NSNumber> f = (x) => { return(NSNumber.FromFloat(x)); };

            Func <string, CAMediaTimingFunction> t = (s) => { return(CAMediaTimingFunction.FromName(s)); };

            switch (this.TransitionStyle)
            {
            case SIAlertViewTransitionStyle.SlideFromBottom:
            {
                RectangleF originalRect = this._ContainerView.Frame;
                RectangleF rect         = originalRect;
                float      locationY    = this.Bounds.Size.Height;
                rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                this._ContainerView.Frame = rect;
                UIView.Animate(
                    duration: 0.3f,
                    delay: 0f,
                    options: UIViewAnimationOptions.TransitionNone,
                    animation: () => { this._ContainerView.Frame = originalRect; },
                    completion: () => { if (action != null)
                                        {
                                            action.Invoke();
                                        }
                    });
            }
            break;

            case SIAlertViewTransitionStyle.SlideFromTop:
            {
                RectangleF rect         = this._ContainerView.Frame;
                RectangleF originalRect = rect;
                float      locationY    = -rect.Size.Height;
                rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                this._ContainerView.Frame = rect;
                UIView.Animate(
                    duration: 0.3f,
                    delay: 0f,
                    options: UIViewAnimationOptions.TransitionNone,
                    animation: () => { this._ContainerView.Frame = originalRect; },
                    completion: () => { if (action != null)
                                        {
                                            action.Invoke();
                                        }
                    });
            }
            break;

            case SIAlertViewTransitionStyle.Fade:
            {
                this._ContainerView.Alpha = 0f;
                UIView.Animate(
                    duration: 0.3f,
                    delay: 0f,
                    options: UIViewAnimationOptions.TransitionNone,
                    animation: () => { this._ContainerView.Alpha = 1f; },
                    completion: () => { if (action != null)
                                        {
                                            action.Invoke();
                                        }
                    });
            }
            break;

            // These two remaining transition styles are not yet supported because I have not yet figured how to properly wire up the Delegate property on CAKeyFrameAnimation

            //case SIAlertViewTransitionStyle.Bounce:
            //{
            //    CAKeyFrameAnimation animation = CAKeyFrameAnimation.GetFromKeyPath(@"transform.scale");
            //    animation.Values = new NSNumber[] { f(0.01f), f(1.2f), f(0.9f), f(1f) };
            //    animation.KeyTimes = new NSNumber[] { f(0f), f(0.4f), f(0.6f), f(1f) };
            //    animation.TimingFunctions = new CAMediaTimingFunction[] { t(CAMediaTimingFunction.Linear.ToString()), t(CAMediaTimingFunction.Linear.ToString()), t(CAMediaTimingFunction.EaseOut.ToString()) };
            //    animation.Duration = 0.5f;
            //    animation.Delegate =


            //    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"transform.scale"];
            //    animation.values = @[@(0.01), @(1.2), @(0.9), @(1)];
            //    animation.keyTimes = @[@(0), @(0.4), @(0.6), @(1)];
            //    animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
            //    animation.duration = 0.5;
            //    animation.delegate = self;
            //    [animation setValue:completion forKey:@"handler"];
            //    [self.containerView.layer addAnimation:animation forKey:@"bouce"];
            //}
            //break;

            //case SIAlertViewTransitionStyle.DropDown:
            //{
            //    CGFloat y = self.containerView.center.y;
            //    CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"position.y"];
            //    animation.values = @[@(y - self.bounds.size.height), @(y + 20), @(y - 10), @(y)];
            //    animation.keyTimes = @[@(0), @(0.5), @(0.75), @(1)];
            //    animation.timingFunctions = @[[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear], [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]];
            //    animation.duration = 0.4;
            //    animation.delegate = self;
            //    [animation setValue:completion forKey:@"handler"];
            //    [self.containerView.layer addAnimation:animation forKey:@"dropdown"];
            //}
            //break;

            // for now, has the same body as the SlideFromTop case;
            case SIAlertViewTransitionStyle.DropDown:
            {
                RectangleF rect         = this._ContainerView.Frame;
                RectangleF originalRect = rect;
                float      locationY    = -rect.Size.Height;
                rect = new RectangleF(rect.Location.X, locationY, rect.Size.Width, rect.Size.Height);
                this._ContainerView.Frame = rect;
                UIView.Animate(
                    duration: 0.3f,
                    delay: 0f,
                    options: UIViewAnimationOptions.TransitionNone,
                    animation: () => { this._ContainerView.Frame = originalRect; },
                    completion: () => { if (action != null)
                                        {
                                            action.Invoke();
                                        }
                    });
            }
            break;

            default:
                break;
            }
        }