Get image from uiview

I want to perform animation compression on UITableVIew. I experimented a bit and found out that the animation is much faster when I reduce the UIImageView with an image of the current state of the table, instead of reducing the presentation of the table.

I captured the image in the method in my main view manager before the animation:

UIGraphicsBeginImageContext(mainTableView.bounds.size);

[resizeContainer.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();

UIGraphicsEndImageContext();

Works like a charm, at least almost. In very rare cases, I get strange graphical crashes where UIImage begins to overlap the toolbar below it.

I just want to make sure I get the image correctly. I understand that you need to understand GraphicContexts.

In short, is my code correct?

thanks

+3
2

iOS 4.0. , .

0

? , . , , :

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];
[mainTableView setFrame:CGRectMake(0,43,320,176)];
[UIView commitAnimations];

, , , - , . , , , , " ", .

0

Source: https://habr.com/ru/post/1722872/


All Articles