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

Can I just load another UIView without using core graphics to render next page? #33

Open
y0unghe opened this issue Jan 17, 2014 · 1 comment · May be fixed by #34
Open

Can I just load another UIView without using core graphics to render next page? #33

y0unghe opened this issue Jan 17, 2014 · 1 comment · May be fixed by #34

Comments

@y0unghe
Copy link

y0unghe commented Jan 17, 2014

In the examples project, every page is rendered using core graphics. I have a UIView want to displaying in the next page, it's a grid view layout page. How to make it to show at the next page in the - (void)renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx method?

@Hless
Copy link

Hless commented Jan 23, 2014

I needed to do just that too, so I went ahead and created an example of how to render a page from UIView. I will create a pull request for the added example in the XCode project.

- (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {

    CGRect bounds = CGContextGetClipBoundingBox(ctx);

    UIView* renderView = [[[UIView alloc] initWithFrame:bounds] autorelease];
    renderView.backgroundColor = [UIColor colorWithHue:index/10.0
                                        saturation:0.8
                                        brightness:0.8
                                             alpha:1.0];


    UILabel* label = [[[UILabel alloc] initWithFrame:bounds] autorelease];
    label.text = [NSString stringWithFormat:@"Page number %d", index];
    label.textAlignment = UITextAlignmentCenter;
    [renderView addSubview:label];

    // View will render upside down if we omit this:
    CGAffineTransform verticalFlip = CGAffineTransformMake(1, 0, 0, -1, 0, bounds.size.height);
    CGContextConcatCTM(ctx, verticalFlip);


    // We call renderInContext on the layer to draw the view onto the context
    [renderView.layer renderInContext:ctx];
}

@Hless Hless linked a pull request Jan 23, 2014 that will close this issue
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

Successfully merging a pull request may close this issue.

2 participants