Menu
  • HOME
  • TAGS

Enable user interaction for gesture recognizer during UIView.animateWithDuration()

ios,swift,uiview,uigesturerecognizer,animatewithduration

You have to use animateWithDuration(_ duration: NSTimeInterval, delay: NSTimeInterval, options: UIViewAnimationOptions, animations: () -> Void, completion: ((Bool) -> Void)?) for that. And provide AllowUserInteraction as an option to allow the user to interact with the view during animation. See the docs for more options....

Need help incrementing a parameter in UIView.animateWithDuration in swift

ios,swift,delay,increment,animatewithduration

for button in options { UIView.animateWithDuration(1.0, delay: increment, usingSpringWithDamping: 0.7, initialSpringVelocity: 0.0, options: nil, animations: { button.center.y -= self.view.bounds.height }, completion: nil) } increment = increment + 0.05 } Besides: Change this let increment = 0.25 To var increment = 0.25 Increase the increment outside animation. Because animateWithDuration is an...

Odd error when capturing function parameter in Swift call to animateWithDuration:Animations:

swift,closures,animatewithduration

Calling methods in the same class are called with an implied self. In this case because of the closure you have to make it explicit: self.animateButton(aButton, step: 1) ...

Stop specific UIViewAnimation block - iOS

ios,objective-c,animation,uiviewanimation,animatewithduration

You can't reach running animation property if you're using UIKit Animations. So I suggest to using Core Animation if you want to modify animation in the runtime of it. And it's too simple to removing alpha of the view like below. CABasicAnimation* fadein= [CABasicAnimation animationWithKeyPath:@"opacity"]; [fadein setToValue:[NSNumber numberWithFloat:1.0]]; [fadein setDuration:0.5];...

UITextField Disapearing

ios,animation,swift,uibutton,animatewithduration

If you're using an iPhone simulator, try using 50 instead of 500 as the screen width is small and your text field is thus displayed off screen joinTextField.frame.origin.x=**50** joinTextField.frame.origin.y=100 override func viewDidLayoutSubviews(){ joinTextField.center = CGPointMake(joinTextField.frame.origin.x-**50**, joinTextField.frame.origin.y) } ...

How to convert a CABasicAnimation to UIView animatewithDuration

ios,objective-c,animation,cabasicanimation,animatewithduration

[UIView animateWithDuration:0.5 delay:1.0 options: UIViewAnimationOptionCurveEaseInOut animations:^{ //self.myView.transform = CGAffineTransformMakeScale(2.0,1.0); self.testview.layer.transform = CATransform3DMakeScale(2.0,1.0,1.0); } completion:^(BOOL finished){ }]; ...

animateWithDuration in UITableViewCell's setSelected method has no effect

ios,objective-c,uitableview,nslayoutconstraint,animatewithduration

Every time you update a autolayout constraint, you have to call layoutIfNeeded, - (void)setSelected:(BOOL)selected animated:(BOOL)animated { [UIView animateWithDuration: 0.5 delay:0 options:UIViewAnimationOptionCurveEaseOut animations:^{ tabConstraint.constant = selected ? 40 : 20; [self layoutIfNeeded]; } completion:nil]; } ...

How to both scroll and stop UIScrollView programmatically?

ios,animation,scroll,uiscrollview,animatewithduration

I think this is something you best do yourself. It may take you a few hours to create a proper library to animate data but in the end it can be very rewarding. A few components are needed: A time bound animation should include either a CADispalyLink or a NSTimer....

swift animate all added views alpha

ios,swift,uiviewanimation,uianimation,animatewithduration

This is because Swift needs to know the kind of objects inside the subviews NSArray before sending methods. NSArray is automatically converted in a swift Array of AnyType objects, thus it doesn't know which kind of objects are extracted from the array. By casting the array to be an array...

Nested animation in iOS: combine animated and non-animated code in animateWithDuration?

ios,objective-c,animation,nested,animatewithduration

The best solution I found out is RZViewActions. Advantages for my case: operate with animations as with objects without nested blocks; serial and parallel animations are "sequences" and "groups" which are objects too created from simple arrays of animations; just take its demo, remove [self.spinner startAnimating];, run and click the...

Collapse A UIImageView From A Center Point

ios,xcode,swift,uiimageview,animatewithduration

You can use scaling using UIView's transform property. It seems like scaling does not allow you to make the value 0 and it goes to the final value without any animation. So, you could basically make the scaling y value negligible like 0.001. imageView.transform = CGAffineTransformMakeScale(1, 0.001) You could also...

Whats the Swift 2.0 animateWithDuration syntax?

swift,swift2,animatewithduration

It turns out it's a very simple fix, just change options: nil to options: []. Working code: UIView.animateWithDuration(0.5, delay: 0.3, options: [], animations: { self.username.center.x += self.view.bounds.width }, completion: nil) ...

How can I animate UILabels from an array to move across the screen with an equal delay between them?

ios,uilabel,uiviewanimation,animatewithduration

The delay is relative to the time at which you create the animation, so, because all of the animations are created at the same time in the loop they all have the same delay. Instead, set the delay to the iteration index (i): [UIView animateWithDuration:0.3 delay:i options:0 animations:^{ ... so...

How to implement a CADisplayLink into a for in loop

ios,swift,for-in-loop,cadisplaylink,animatewithduration

You'll only want to add one CADisplayLink. var displayLink: CADisplayLink! override func viewDidLoad() { // ... for loopNumber in 0...100 { // ... } displayLink = CADisplayLink(target: self, selector: Selector("moveDots")) displayLink.frameInterval = frameInterval displayLink.addToRunLoop(NSRunLoop.mainRunLoop(), forMode: NSRunLoopCommonModes) } func moveDots() { for dot in self.subviews { // calculate its new position...

Shrink and Transform UIButton

ios,animation,uibutton,animatewithduration

You can add this code inside your animation block. Which scale the button to half of its size. button.transform = CGAffineTransformMakeScale(0.5, 0.5); ...

Why does animateWithDuration fade out but not in?

swift,uiviewanimation,swift2,animatewithduration,xcode7-beta2

The animation happens in a completion block, so basically you are running two animations at the same time, I indicate what is happening in the code in the code below. func animateMessage(label: UILabel, delay: Double){ label.alpha = 0.0 //1 - Start animation 1 UIView.animateWithDuration(1.2, animations: { //3 - Finish animation...

animateWithDuration:animations:completion: in Swift

closures,swift,ios8,animatewithduration

This is a good one, tricky! The issue is in your completion block... A. I would begin by rewriting it like this: (not the final answer, but on our way there!) { _ in self.storedCells.removeAtIndex(1) } (the _ in place of the "finished" Bool, to indicate to the reader that...

Repeating NSTimer causes truncated animateWithDuration on first animation

objective-c,nstimer,animatewithduration

I'd try enabling the UIViewAnimationOptionBeginFromCurrentState option in your animation code and see if that helps

Continuous animation in iOS?

ios,uiview,catransform3d,animatewithduration,uilongpressgesturerecogni

I am not sure if I understood your question correctly, here I share a method that listens to longPressRecognizer and animates a view as long as user presses onto that view. As user stops pressing, view animates back to its default state. You can check if user gesture satisfies your...