uiviewanimation

Auto Layout constraint change does not animate

强颜欢笑 提交于 2019-11-28 23:50:50
I was learning the auto layout with animations from the tutorial http://weblog.invasivecode.com/post/42362079291/auto-layout-and-core-animation-auto-layout-was and things were working perfect. When I tried to use this concept in my application, trying to animate a settings screen(a UIView) from bottom to top,it works great when the settings screen is just an empty UIView, But in case I add a UILabel as a subview to this settings screen, the animation just vanishes. On removing this UILabel form the settings screen, the animation is visible. Here are the outlets that I have connected __weak

iOS - completion block in UIView animateWithDuration gets called too early

非 Y 不嫁゛ 提交于 2019-11-28 22:44:53
I'm trying to do some animation when a table view cell gets selected. For some reason, the completion block is getting called way too early. Even setting the duration to 10 seconds, the completion block gets called immediately. [UIView animateWithDuration:10.0 animations:^{ message.frame = newFrame; } completion:^(BOOL finished) { NSLog(@"DONE???"); }]; Any thoughts on why this is happening? Thanks. From the UIView documentation : completion A block object to be executed when the animation sequence ends. This block has no return value and takes a single Boolean argument that indicates whether

UIView.animateWithDuration swift loop animation

寵の児 提交于 2019-11-28 22:36:09
In ViewController.Swift I managed to make a box animate from one point to another. I thought it would be easy to loop this so the box will animate to one point and then animate back to its original position and then loop again. I have managed to move the object to a position and in "complete" move it back again, but that doesn't make i loop. How can this be achieved? I thought maybe this could work but i honestly don't know: let boxmoves = [CGRect(x: 120, y: 220, width: 100, height: 100), CGRect(x: 120, y: 120, width: 100, height: 100)] for boxmove in boxmoves { coloredSquare.frame = boxmove }

iOS: a Complete 360 Degree-Rotation Using Block, Not CABasicAnimation

こ雲淡風輕ζ 提交于 2019-11-28 21:42:01
It should be something really simple, but I have not been successful in getting this to work using blocks. There are questions and answers to this, but all of them I found are solved by the use of CABasicAnimation and not by UIView Block-Based Animation, which is what I am after. The following code doesn't work (Block-Based), no animation: CGAffineTransform spin = CGAffineTransformRotate(spiningView.transform, DEGREES_RADIANS(360)); CATransform3D identity = CATransform3DIdentity; CATransform3D spin2 = CATransform3DRotate(identity, DEGREES_RADIANS(360), 0.0f, 0.0f, 1.0f); [UIView

How do you animate the sublayers of the layer of a UIView during a UIView animation?

大憨熊 提交于 2019-11-28 20:46:12
In a UIView animation for a view, you can animate its subviews being laid out by including UIViewAnimationOptionLayoutSubviews in the options parameter of [UIView animateWithDuration:delay:options:animations:completion:] . However, I cannot find a way to animate it laying out its sublayers when they are not some view's backing layer; they would just jump into place to match the new bounds of the view. Since I'm working with layers and not views, it seems like I have to use Core Animation instead of UIView animation, but I don't know how (and when) to do this such that the layer animation would

How to stop and reverse a UIView animation?

僤鯓⒐⒋嵵緔 提交于 2019-11-28 19:35:43
I have animated a UIView so that it shrinks when the user touches a toggle button and it expands back to its original size when the user touches the button again. So far everything works just fine. The problem is that the animation takes some time - e.g. 3 seconds. During that time I still want the user to be able to interact with the interface. So when the user touches the button again while the animation is still in progress the animation is supposed to stop right where it is and reverse. In the Apple Q&As I have found a way to pause all animations immediately: https://developer.apple.com

How to animate a UIView with constraints in Swift?

空扰寡人 提交于 2019-11-28 18:35:16
In my contrived example, I have the following single view: As you can see, it consists of a few simple constraints: Align horizontal and vertical centers, Height (set to a constant) Leading and trailing spaces (set to constant) What I'm seeking to achieve is to have this redish/pinkish view "come in" from the top. Traditionally, in a constraint-less world, I would simply modify the frame inside of UIView.animateWithDuration , however I'm not sure how I do the similar in a constraint world. To reiterate my question, how can I make my view start out of scene and animate the view flying in from

iOS: How to convert UIViewAnimationCurve to UIViewAnimationOptions?

跟風遠走 提交于 2019-11-28 17:25:15
The UIKeyboardAnimationCurveUserInfoKey has a UIViewAnimationCurve value. How do I convert it to the corresponding UIViewAnimationOptions value for use with the options argument of +[UIView animateWithDuration:delay:options:animations:completion:] ? // UIView.h typedef enum { UIViewAnimationCurveEaseInOut, // slow at beginning and end UIViewAnimationCurveEaseIn, // slow at beginning UIViewAnimationCurveEaseOut, // slow at end UIViewAnimationCurveLinear } UIViewAnimationCurve; // ... enum { // ... UIViewAnimationOptionCurveEaseInOut = 0 << 16, // default UIViewAnimationOptionCurveEaseIn = 1 <<

UIView animations with autoreverse

狂风中的少年 提交于 2019-11-28 16:22:31
I have a problem with the setting UIViewAnimationOptionAutoReverse . Here is my code. CALayer *aniLayer = act.viewToChange.layer; [UIView animateWithDuration:2.0 delay:1.0 options:(UIViewAnimationCurveLinear | UIViewAnimationOptionAutoreverse) animations:^{ viewToAnimate.frame = GCRectMake(1,1,100,100); [aniLayer setValue:[NSNumber numberWithFloat:degreesToRadians(34)] forKeyPath:@"transform.rotation"]; } completion:nil ]; The problem is that, after the animation has reversed, the view jumps back to the frame set in the animation block. I want the view to grow and "ungrow" and stop at its

How to pause and resume UIView Animation (without Block Animation)?

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 14:39:51
How do you pause and resume UIView Animations? (without block animations) I was having the hardest time figuring this out, so here is my source below on how to do it. John Riselvato How to pause and resume UIView Animations: This will cover how to do the above without block animations. (People do still wish to support 3.0 and up). This only allows for pausing once the animation has met the set location. For how to pause an animation in the middle of an animation, i suggest using CALayers as such: CALayer* myLayer = [self.myUIView.layer presentationLayer]; CGRect frameStop = myLayer.frame;