Re: UIScrollView to UIImage
Re: UIScrollView to UIImage
- Subject: Re: UIScrollView to UIImage
- From: Trygve Inda <email@hidden>
- Date: Sun, 28 Jul 2013 08:31:28 -0700
- Thread-topic: UIScrollView to UIImage
Update:
CGRect rect = [scrollView bounds];
UIGraphicsBeginImageContextWithOptions(rect.size,YES,0.0f);
CGContextRef context = UIGraphicsGetCurrentContext();
[scrollView.layer renderInContext:context];
UIImage *capturedImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
The scroll view is full screen (768w x 955h) and the image in the scrollview
is 1500w x 955h so it can only scroll right-left.
If I run this code with the scrollview scrolled all the way to the left,
everything is fine. The resulting image is the leftmost chuck of the image
in the scroillview.
However if I scroll the scrollview 100 pixels to the left (so the scrollview
has 100 pixels off the left edge of the screen, 768 pixels on screen and 632
pixels off the right edge of the screen)....
The resulting image from the above code has 100 pixels of black on the left
side, and then the correct image for the rest of it.
Changing the first line to:
CGRect rect = [scrollView frame];
produces the exact same result. So somehow, the above code can't handle when
the scrollview is scrolled away from 0,0.
How can I fix this?
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden