Write in hard times.
- I implemented some animation effects with ideas provided by BOC, the author of the brief book.
-
Github source address :github.com/JonHory/Tra…
-
With modal transitions, Set modalTransitionStyle UIModalTransitionStyleCrossDissolve, set the modalPresentationStyle to UIModalPresentationOverFullScreen
Zoom in and out of pictures
1. Create a UIImageView and a CGRect to hold the image information and the image frame information. Use – (CGRect)convertRect:(CGRect)rect toView:(nullable UIView *)view; Method to get the relative position of the picture. 2. Animate the view as it will appear
- (void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; [UIView animateWithDuration: AnimationTime animations: ^ {/ / here is free to play the self. The backgroundColor = [UIColor greenColor]; self.currentIV.frame = CGRectMake(0, 0, 200, 200); self.currentIV.center = CGPointMake(self.view.center.x, 200); } completion:^(BOOL finished) { }]; }Copy the code
3. Returned click event handling
- (void)back{ [UIView animateWithDuration:AnimationTime animations:^{ if ([self.type isEqualToString:@"vv"]) { Self. The center = CGPointMake (self. View. Center. X, the self. The bounds. Size. The height * 1.5); }else { self.currentIV.frame = self.oldFrame; self.view.backgroundColor = [UIColor clearColor]; } } completion:^(BOOL finished) { [self dismissViewControllerAnimated:NO completion:nil]; }]; }Copy the code
4. Just like that, the effect is out
Boss direct hire animation effect
1. In the current UIViewController, use a UIImageView to save the screenshot
-(UIImage *)screenImageWithSize:(CGSize )imgSize{ UIGraphicsBeginImageContext(imgSize); CGContextRef context = UIGraphicsGetCurrentContext(); AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication].delegate; // Get the appdelegate so that the current window can be taken as a screenshot [app.window.layer renderInContext:context]; UIImage * img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; }Copy the code
2. Create a subtraction method for the next VC to use in the current VC
[self presentViewController:vc animated:NO completion:nil]; [UIView animateWithDuration:0.3 animations:^{self.screenshot.bounds = CGRectMake(50, 50, 50, SCREEN.width - 100, SCREEN.height - 100); } completion:^(BOOL finished) {// This is the subtracting method =_= At the end of the animation, change the background block frame [vc changeBigView];}];Copy the code
3. When the next VC returns, the screenshot view of the current VC is removed.
[weakSelf.screenshot removeFromSuperview];Copy the code
4. Thus, the BOSS Zhipin animation effect appears.