core-animation

Core Animation for UIView.frame

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-20 03:30:21
问题 I'm trying to do a simple animation of moving the frame of two views. Basically hiding the Ad until it is loaded, and then move the frame up from the bottom, along with the view that starts at the bottom, and then will move up also when the Ad pushes it up. The start and end positions are correct, but I don't see it being animated. Is this correct? Thanks. CAKeyframeAnimation *animation = [CAKeyframeAnimation animationWithKeyPath:@"frame"]; animation.duration = 1.0; CGRect adFrame =

Core Animation rotating a layer around arbitrary point

人盡茶涼 提交于 2019-12-20 02:16:18
问题 How can I rotate a layer using Core Animation around an arbitrary point? ( In my case a point that is not inside the layer I want to rotate ) I prefer doing this without changing the anchor point, because unless I get something wrong every time I change the anchor point it also changes the position of the layer. I tried something like that but it didn't work: [UIImageView beginAnimations:nil context:nil]; CATransform3D rotationTransform = CATransform3DIdentity; rotationTransform =

How can I animate the height of a CALayer with the origin coming from the bottom instead of the top?

别等时光非礼了梦想. 提交于 2019-12-19 23:59:43
问题 I want to animate a simple CALayer to move up and down in response to incoming data (bars on a graphic equaliser) The CALayer should remain fixed along the bottom and move up and down as the height is animated. Can anybody advise on the best way to achieve this without having to animate the origin y coord as well as the height? 回答1: If you want the layer to always grow and shrink from the bottom, then you should set your own anchorPoint on the layer that is the bottom. The anchor point is

Are most games on the IPhone done with OpenGL ES?

心已入冬 提交于 2019-12-19 19:51:41
问题 I was just wondering if most games on the iPhone are done in OpenGL ES as opposed to using Quartz and Core Animation. Are Quartz and Core Animation mostly used for just creating slick interfaces? Or if there is a point with games where OpenGL probably has to be used over using other tools? 回答1: For efficiency reasons OpenGL ES is you best choice for games, unless your writing a "simple" board game or card game (like Solitaire). In this case Core Animation would be a good fit. 回答2: You should

CALayer renderInContext

二次信任 提交于 2019-12-19 18:58:18
问题 I use CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; rotationAndPerspectiveTransform.m34 = 1.0 / -500; It's success, but I use "renderInContext:context" get CGImage from context, I found the image effect is not changed ! How can I get this effect image from CALayer? 回答1: My Original reply follows bellow. It was valid at the time I posted it, but Apple does not allow the usage of UIGetScreenImage anymore. To the best of my knowledge after the launch of iOS4 there's no

CALayer renderInContext

浪尽此生 提交于 2019-12-19 18:57:27
问题 I use CATransform3D rotationAndPerspectiveTransform = CATransform3DIdentity; rotationAndPerspectiveTransform.m34 = 1.0 / -500; It's success, but I use "renderInContext:context" get CGImage from context, I found the image effect is not changed ! How can I get this effect image from CALayer? 回答1: My Original reply follows bellow. It was valid at the time I posted it, but Apple does not allow the usage of UIGetScreenImage anymore. To the best of my knowledge after the launch of iOS4 there's no

How do I animate opacity using swift?

北城余情 提交于 2019-12-19 18:28:46
问题 Could someone please provide me with an example of animating the opacity of an Image View in swift?? I couldn't even find a good example in objective c func showCorrectImage(element: AnyObject){ var animation : CABasicAnimation = CABasicAnimation(keyPath: "opacity"); animation.delegate = self animation.fromValue = NSValue(nonretainedObject: 0.0) animation.toValue = NSValue(nonretainedObject: 1.0) animation.duration = 1.0 element.layer?.addAnimation(animation, forKey: nil) } I think I have

iOS: Should I Add UIViews or CALayers for animation?

删除回忆录丶 提交于 2019-12-19 17:34:48
问题 Let's say I want to add 50 images to a view for the purpose of animating them. And let's suppose I'm planning on using Core Animation (e.g., CABasicAnimation) rather than "UIView" animation. Am I better off implementing this by adding 50 subviews or 50 sublayers? Does it make a difference? Thanks. 回答1: As I describe here, I've used both UIViews and CALayers in animations and found a negligible performance difference between them. UIViews are very lightweight wrappers around the layers. Also,

Set contents of CALayer to animated GIF?

陌路散爱 提交于 2019-12-19 11:52:25
问题 Is it possible to set the contents of a CALayer to an animated GIF and have it display that animation? I know that I can set the contents to an image like so: CALayer* subLayer = [CALayer layer]; NSImage *image = [[NSImage alloc] initWithData:data]; subLayer.contents = image; And the image will show, but if it's animated, the animation will not display. Is the only solution to get the individual frames for the GIF, get the frame rate, then change the content of the sublayer according to the

iOS UIView Animation CATransform3DMakeRotation confusion

天大地大妈咪最大 提交于 2019-12-19 10:37:22
问题 I have a UIView that I am trying to animate flipping down, while having its axis at the bottom of the view. E.g.: To do this, I am trying to use a UIView animation: [UIView animateWithDuration:3 delay:0 options:UIViewAnimationCurveEaseOut animations:^{ // Flip Down top3.layer.anchorPoint = CGPointMake(0.5, 1.0); top3.layer.transform = CATransform3DMakeRotation(M_PI, 1, 0, 0); } completion:^(BOOL finished) { // Reset? //top3.transform = CGAffineTransformMakeScale(1, 1); }]; Right now it isn't