I have a view which is placed at the particular transform. i want to take a screenshot of that view but after render it not taking the value of transform.
My View
dragView = [[DragbleView alloc] initWithFrame:CGRectMake(10, 200, 200, 90)];
dragView.contentView = textField;
dragView.transform = CGAffineTransformMakeRotation (-0.663247);
[self.view addSubview:dragView];
My Screenshot Code
UIGraphicsBeginImageContextWithOptions(view.bounds.size, NO, [UIScreen mainScreen].scale);
[view drawViewHierarchyInRect:view.bounds afterScreenUpdates:YES];
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
Problem After taking screenshot it always comes horizontal neglecting the value of transform
You can take a snapshot of the parent view of all subviews that you want to keep in the snapshot image, the parent view is self.view
. Then the transform of dragView
is kept.
UIImage *mainImage = [self imageWithView:self.view];
And you forget UIGraphicsEndImageContext()
in your btnSaveClicked
function.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.