core-animation

AVFoundation: Fit Video to CALayer correctly when exporting

徘徊边缘 提交于 2020-05-28 03:29:32
问题 Problem: I'm having issues getting videos I'm creating with AVFoundation to show in the VideoLayer, a CALayer , with correct dimensions. Example: Here is what the video should look like (as its displayed to the user in the app) However, here's the resulting video when it's exported: Details As you can see, its meant to be a square video, with green background, with the video fitting to a specified frame. However, the resulting video doesn't fit the CALayer used to contain it (see the black

How to perform kCATransitionPush animation without any transparency / fade effects [duplicate]

假装没事ソ 提交于 2020-02-21 11:10:11
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: iPhone CATransition adds a fade to the start and end of any animation? I'm trying to duplicate the "slide up from the bottom" animation that [UIViewController presentModalViewController:animated:] performs but without calling it because I don't want a modal view. The below core animation code comes very close but appears to be changing transparency values of the views during it. At the start of the animation you

SpriteKit SKScene add AVCaptureVideoPreviewLayer CALayer as background not working

柔情痞子 提交于 2020-02-04 05:24:33
问题 I'm attempting to add the AVCaptureVideoPreviewLayer CALayer as the background to my SKScene. I can add the CALayer to the scene, but no matter what attempts at ordering the CALayer is always the top most object. In the didMoveToView I have the function: - (void) didMoveToView:(SKView *)view { [self addVideo]; } Which calls the addVideo function: -(void) addVideo { AVCaptureSession *captureSession = [[AVCaptureSession alloc] init]; captureSession.sessionPreset = AVCaptureSessionPresetHigh;

Purpose of CALayer?

允我心安 提交于 2020-02-04 02:40:48
问题 I'm slightly used as to what the purpose of CALayer's existence is. Why not just put the properties in a UIView? Thanks. 回答1: A CALayer represents a completely different "thing" from a UIView. A CALayer only deals with drawing itself, and encapsulating the information needed to do that. A view, on the other hand, owns one or many layers, which it uses to draw itself. A view has many other functions and properties though, that are unrelated to its representation on the screen. I would

Why does a PNG image sometimes get blurry depending on its position in a view

为君一笑 提交于 2020-01-31 05:22:26
问题 I have noticed that when placing PNG images into a view using IB and/or animating those images to various positions around a view, the image can sometimes get a slight blur. In most cases I can remedy the blur by adding .5 of a pixel to the images position. [lbLiteButton.layer setPosition:CGPointMake(140.5,159.5)]; Sometimes I have to adjust both x and y like above. Sometimes I only have to adjust x or y. I remember reading somewhere that this has to do with the size of the image and how core

CAEmitterCell with 3D rotation

拟墨画扇 提交于 2020-01-30 08:11:49
问题 I'm trying to reproduce pieces of small paper falling from top effect, using CAEmitterLayer & CAEmitterCell. So far, I got the 2D animation of it, But I'm having difficulty to make each cell to rotate when falling. How to I apply random rotation on each particle? I tried with 3D Transform with no success so far. This is what I got: -(void) configureEmitterLayer { self.emitterLayer = [CAEmitterLayer layer]; self.emitterLayer.emitterPosition = CGPointMake(self.backgroundContainer.bounds.size

CAEmitterCell with 3D rotation

徘徊边缘 提交于 2020-01-30 08:11:26
问题 I'm trying to reproduce pieces of small paper falling from top effect, using CAEmitterLayer & CAEmitterCell. So far, I got the 2D animation of it, But I'm having difficulty to make each cell to rotate when falling. How to I apply random rotation on each particle? I tried with 3D Transform with no success so far. This is what I got: -(void) configureEmitterLayer { self.emitterLayer = [CAEmitterLayer layer]; self.emitterLayer.emitterPosition = CGPointMake(self.backgroundContainer.bounds.size

iPhone. Particle system performance

余生长醉 提交于 2020-01-24 17:27:05
问题 I try to draw rain and snow as particle system using Core Graphics . In simulator rendering proceeded fine but when I run my app on real device rendering is slow down. So, advise me please approaches to increase particle system drawing performance on iPhone . May be I should use OpenGL for this or CoreAnimation ? 回答1: OpenGL would be the lowest level to drop to for the rendering, so should offer the best performance (if done right). CoreAnimation would be close enough if there are not too

Swift UIView animateWithDuration completion closure called immediately

大憨熊 提交于 2020-01-23 05:05:03
问题 I'm expecting the completion closure on this UIView animation to be called after the specified duration, however it appears to be firing immediately... UIView.animateWithDuration( Double(0.2), animations: { self.frame = CGRectMake(0, -self.bounds.height, self.bounds.width, self.bounds.height) }, completion: { finished in if(finished) { self.removeFromSuperview() } } ) Has anyone else experienced this? I've read that others had more success using the center rather than the frame to move the

Swift UIView animateWithDuration completion closure called immediately

孤人 提交于 2020-01-23 05:04:26
问题 I'm expecting the completion closure on this UIView animation to be called after the specified duration, however it appears to be firing immediately... UIView.animateWithDuration( Double(0.2), animations: { self.frame = CGRectMake(0, -self.bounds.height, self.bounds.width, self.bounds.height) }, completion: { finished in if(finished) { self.removeFromSuperview() } } ) Has anyone else experienced this? I've read that others had more success using the center rather than the frame to move the