Due to work needs, high imitation [miaobo] Demo core functions are basically completed. The functions of audio and video collection, stream pushing, built-in music player system, video pull-stream playing and instant communication in live chat rooms have been completed at the player end. However, today is not to talk about these seemingly lofty things, today I will continue to talk about some details of the live broadcast APP, ha ha, don’t worry, I will systematically write an article about the iOS live broadcast APP after this busy period of time, you don’t want to miss, please pay attention!! .

Today we are going to talk about the animation of thumbs up in the live streaming APP. Look at the picture below. This is the interface I made after miaobo. These animated pictures are all captured from meowbo APP. If you don’t know how to capture an APP picture material, there is an introduction at the back of the article, which is definitely enough surprise.




Live thumbs-up animation. GIF

Let’s get to the point: The implementation logic of thumbs-up animation: 1. Click on the screen to trigger the click event, generate an imageView and add a random image to it. 2. Set the animation execution 4, set an end frame value for the imageView 5, end the animation 6, destroy the imageView this is the general implementation of the animation logic, there are many details and parameter configuration problems, code annotation is very clear, directly look at the code OK:

- (void)touch began :(NSSet *)touches withEvent:(UIEvent *)event {// touch [self praiseAnimation]; }Copy the code
#pragma mark - (void)praiseAnimation {UIImageView *imageView = [[UIImageView alloc] init]; CGRect frame = self.view.frame; Imageview. frame = CGRectMake(frame.size-40, frame.size-height-65, 30, 30); // Initialize imageView opacity to 0 imageView.alpha = 0; imageView.backgroundColor = [UIColor clearColor]; imageView.clipsToBounds = YES; // Take 0.2 seconds to change the imageView opacity to 1.0, zoom in 1.3x, then zoom in 1.1x, [UIView animateWithDuration:0.2 animations:^{imageView.alpha = 1.0;  imageView.frame = CGRectMake(frame.size.width - 40, frame.size.height - 90, 30, 30); CGAffineTransform transfrom = CGAffineTransformMakeScale (1.3, 1.3);  imageView.transform = CGAffineTransformScale(transfrom, 1, 1); }]; [self.view addSubview:imageView]; CGFloat finishX = frame.sie.width -round (random() % 200); CGFloat finishX = frame.sie.width -round (random() % 200); // The Y value of the animation end point CGFloat finishY = 200; CGFloat scale = round(random() % 2) + 0.7; // Generate a random number as the speed parameter CGFloat speed = 1 / round(random() % 900) + 0.6; NSTimeInterval duration = 4 * speed; Duration = 2.412346; if (duration == INFINITY) duration = 2.412346; Int imageName = round(random() % 8); int imageName = round(random() % 8); [UIView beginAnimations:nil context:(__bridge void *_Nullable)(imageView)]; / / set the animation time [UIView setAnimationDuration: duration]; Imageview. image = [UIImage imageNamed:[NSString stringWithFormat:@"good%d_30x30_.png",imageName]]; Frame imageView.frame = CGRectMake(finishX, finishY, 30 * scale, 30 * scale); / / set the fading effect, the time here is best and animation at the same time [UIView animateWithDuration: duration animations: ^ {imageView. Alpha = 0;}]. // End the animation, Call onAnimationComplete: finished: context: function [UIView setAnimationDidStopSelector:@selector(onAnimationComplete:finished:context:)]; / / set the animation agent [UIView setAnimationDelegate: self]. [UIView commitAnimations]; }Copy the code
/// destroy iamgeView - (void)onAnimationComplete:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context{ UIImageView *imageView = (__bridge UIImageView *)(context); [imageView removeFromSuperview]; imageView = nil; }Copy the code

This completes the simple like function, very simple!

Special reminder:

// Generate a random number as the speed parameter CGFloat speed = 1 / round(random() % 900) + 0.6; NSTimeInterval duration = 4 * speed; NSLog (@ "time - % f", duration).Copy the code

If you run the above code and print the result, it will occasionally print inf,inf means infinity, which means you will have a picture stuck there, which will be awkward.




50A7E962-AC81-4198-A567-2F587D1AFE12.png

So add this judgment:

Duration = 2.412346; if (duration == INFINITY) duration = 2.412346;Copy the code

The following is an absolute big Easter egg: Download and install the iOS Images Extractor on your Mac. 2. Download the APP you need to grab the material from the iTunes AppStore. 3




B498B849-4B22-451F-89F4-9253186BE581.png

  • The APP IPA file displayed in Finder




    87A0C97F-E041-4A4B-9A34-DC69EE91809A.png

4. Open the iOS Images Extractor, directly drag the APP IPA in, click Start and wait for a few seconds, OK is finished.




2E845738-9BA5-4B17-8B6D-15716B02D111.png

5. Find APP material in the download file (you can set the file saving path by yourself, no further details)




CC37D6CF-E395-48F9-A3A9-2D0E707317D9.png

Is it enough surprise, using iOS images Extractor to grab the images in the APP is so simple, in the future also don’t worry about writing Demo interface ugly to see. Haha, so much for today, like to add attention to it!!