SLPagingView icon indicating copy to clipboard operation
SLPagingView copied to clipboard

Twitter style other title appears on screen

Open boazin opened this issue 9 years ago • 0 comments

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];
    });

boazin avatar Apr 11 '15 21:04 boazin