Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Twitter style other title appears on screen #26

Open
boazin opened this issue Apr 11, 2015 · 0 comments
Open

Twitter style other title appears on screen #26

boazin opened this issue Apr 11, 2015 · 0 comments

Comments

@boazin
Copy link

boazin commented Apr 11, 2015

I'm trying to have a twitter style headers (titles replacing one another).
I'm using storyboard controllers.
When the view loads I get this image:
screen shot 2015-04-12 at 12 21 09 am
When I just touch the swipe, I get what I expected to see - the "Feedme" title disappears (appears nicely when actually swiping to the second controller) - like so:
screen shot 2015-04-12 at 12 21 19 am

How can I make it appear correctly on initial load.

The code:

    MainTabBarViewController *c = [self.storyboard instantiateViewControllerWithIdentifier:@"tabBarController"];
    c.selectedIndex = 1; //feed
    UINavigationController *nav = (UINavigationController *)[c.childViewControllers objectAtIndex:1];
    SLPagingViewController *pageViewController = (SLPagingViewController *)[nav.viewControllers objectAtIndex:0];
    pageViewController.navigationSideItemsStyle = SLNavigationSideItemsStyleDefault;

    pageViewController.pagingViewMovingRedefine = ^(UIScrollView *scrollView, NSArray *subviews){
        float mid   = [UIScreen mainScreen].bounds.size.width/2 - 45.0;
        float width = [UIScreen mainScreen].bounds.size.width;
        CGFloat xOffset = scrollView.contentOffset.x;
        int i = 0;
        for(UILabel *v in subviews){
            CGFloat alpha = 0.0;
            if(v.frame.origin.x < mid)
                alpha = 1 - (xOffset - i*width) / width;
            else if(v.frame.origin.x >mid)
                alpha=(xOffset - i*width) / width + 1;
            else if(v.frame.origin.x == mid-5)
                alpha = 1.0;
            i++;
            v.alpha = alpha;
        }
    };

    [pageViewController setCurrentIndex:0 animated:NO];
    pageViewController.needToShowPageControl = YES;

    dispatch_async(dispatch_get_main_queue(), ^{
        [self presentViewController:c animated:YES completion:nil];
    });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant