Beispiel #1
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            var orange = UIColor.FromRGBA((255f / 255f), 69.0f / 255, 0.0f / 255, 1.0f);
            var grey   = UIColor.FromRGBA(.84f, .84f, .84f, 1.0f);

            var img1 = new UIImageView(UIImage.FromBundle("Gear").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));
            var img2 = new UIImageView(UIImage.FromBundle("Profile").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));
            var img3 = new UIImageView(UIImage.FromBundle("Chat").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));

            var titles             = new [] { img1, img2, img3 };
            var views              = new [] { ViewWithColor(orange), ViewWithColor(UIColor.Yellow), ViewWithColor(grey) };
            var pageViewController = new PagingViewController(titles, UIColor.White, views, false);

            if (twitter)
            {
                pageViewController.MovePageAction = (scrollView, subviews) =>
                {
                    var xOffset = scrollView.ContentOffset.X;
                    int i       = 0;
                    foreach (var v in subviews)
                    {
                        nfloat alpha = 0.0f;
                        if (v.Frame.X < 145)
                        {
                            alpha = 1 - (xOffset - i * 320) / 320;
                        }
                        else if (v.Frame.X > 145)
                        {
                            alpha = (xOffset - i * 320) / 320 + 1;
                        }
                        else if (v.Frame.X == 140)
                        {
                            alpha = 1.0f;
                        }
                        i++;
                        v.Alpha = alpha;
                    }
                };
            }
            else
            {
                pageViewController.MovePageAction = (scrollView, subviews) =>
                {
                    int i = 0;
                    foreach (UIImageView v in subviews)
                    {
                        var c = grey;
                        if (v.Frame.X > 45 &&
                            v.Frame.X < 145)
                        {
                            // Left part
                            c = CreateGradient(v.Frame.X, 46, 144, orange, grey);
                        }
                        else if (v.Frame.X > 145 &&
                                 v.Frame.X < 245)
                        {
                            // Right part
                            c = CreateGradient(v.Frame.X, 146, 244, grey, orange);
                        }
                        else if (v.Frame.X == 145)
                        {
                            c = orange;
                        }
                        v.TintColor = c;
                        i++;
                    }
                };
            }

            var nav = new UINavigationController(pageViewController);

            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.RootViewController = nav;
            window.BackgroundColor    = UIColor.White;

            window.MakeKeyAndVisible();

            return(true);
        }
Beispiel #2
0
        //
        // This method is invoked when the application has loaded and is ready to run. In this
        // method you should instantiate the window, load the UI into it and then make the window
        // visible.
        //
        // You have 17 seconds to return from this method, or iOS will terminate your application.
        //
        public override bool FinishedLaunching(UIApplication app, NSDictionary options)
        {
            var orange = UIColor.FromRGBA((255f / 255f), 69.0f / 255, 0.0f / 255, 1.0f);
            var grey = UIColor.FromRGBA(.84f, .84f, .84f, 1.0f);

            var img1 = new UIImageView(UIImage.FromBundle("Gear").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));
            var img2 = new UIImageView(UIImage.FromBundle("Profile").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));
            var img3 = new UIImageView(UIImage.FromBundle("Chat").ImageWithRenderingMode(UIImageRenderingMode.AlwaysTemplate));

            var titles = new [] { img1, img2, img3 };
            var views = new [] { ViewWithColor(orange), ViewWithColor(UIColor.Yellow), ViewWithColor(grey) };
            var pageViewController = new PagingViewController(titles, UIColor.White, views, false );

            if(twitter){
                pageViewController.MovePageAction = (scrollView, subviews) =>
                    {
                        var xOffset = scrollView.ContentOffset.X;
                        int i = 0;
                        foreach(var v in subviews){
                            nfloat alpha = 0.0f;
                            if(v.Frame.X < 145)
                                alpha = 1 - (xOffset - i*320) / 320;
                            else if(v.Frame.X >145)
                                alpha=(xOffset - i*320) / 320 + 1;
                            else if(v.Frame.X == 140)
                                alpha = 1.0f;
                            i++;
                            v.Alpha = alpha;
                        }
                    };
            } else {
                pageViewController.MovePageAction = (scrollView, subviews) =>
                    {
                        int i = 0;
                        foreach (UIImageView v in subviews) {
                            var c = grey;
                            if(v.Frame.X > 45
                                && v.Frame.X < 145){
                                // Left part
                                c = CreateGradient(v.Frame.X, 46, 144, orange, grey);
                            } else if(v.Frame.X > 145
                                && v.Frame.X < 245){
                                // Right part
                                c = CreateGradient(v.Frame.X, 146, 244, grey, orange);
                            }else if(v.Frame.X == 145){
                                c = orange;
                            }
                            v.TintColor= c;
                            i++;
                        }
                    };
            }

            var nav = new UINavigationController(pageViewController);
            window = new UIWindow(UIScreen.MainScreen.Bounds);
            window.RootViewController = nav;
            window.BackgroundColor = UIColor.White;

            window.MakeKeyAndVisible();

            return true;
        }