iOS Segue – Left to Right –

This is how I achieve the effect without requiring a nav-controller. Try this instead: Swift 4: import UIKit class SegueFromLeft: UIStoryboardSegue { override func perform() { let src = self.source let dst = self.destination src.view.superview?.insertSubview(dst.view, aboveSubview: src.view) dst.view.transform = CGAffineTransform(translationX: -src.view.frame.size.width, y: 0) UIView.animate(withDuration: 0.25, delay: 0.0, options: .curveEaseInOut, animations: { dst.view.transform = CGAffineTransform(translationX: 0, … Read more

How to rotate image in Swift?

set ImageView image ImageView.transform = ImageView.transform.rotated(by: CGFloat(M_PI_2)) Swift 5 ImageView.transform = ImageView.transform.rotated(by: .pi) // 180˚ ImageView.transform = ImageView.transform.rotated(by: .pi / 2) // 90˚ ImageView.transform = ImageView.transform.rotated(by: .pi * 1.5) // 270˚

Swap rootViewController with animation?

You can use UIView.transition(with: view) to replace the rootViewController of a UIWindow: guard let window = UIApplication.shared.keyWindow else { return } let storyboard = UIStoryboard(name: “Main”, bundle: nil) let vc = storyboard.instantiateViewController(withIdentifier: “MainTabbar”) // Set the new rootViewController of the window. // Calling “UIView.transition” below will animate the swap. window.rootViewController = vc // A mask … Read more

How to switch automatically between viewPager pages

You can use Timer for this purpose. The following code is self explanatory: // ————————————————————————— Timer timer; int page = 1; public void pageSwitcher(int seconds) { timer = new Timer(); // At this line a new Thread will be created timer.scheduleAtFixedRate(new RemindTask(), 0, seconds * 1000); // delay // in // milliseconds } // this … Read more

UIView Hide/Show with animation

In iOS 4 and later, there’s a way to do this just using the UIView transition method without needing to import QuartzCore. You can just say: Objective C [UIView transitionWithView:button duration:0.4 options:UIViewAnimationOptionTransitionCrossDissolve animations:^{ button.hidden = YES; } completion:NULL]; Swift UIView.transition(with: button, duration: 0.4, options: .transitionCrossDissolve, animations: { button.hidden = false }) Previous Solution Michail’s solution … Read more

UIView animateWithDuration doesn’t animate cornerRadius variation

tl;dr: Corner radius is not animatable in animateWithDuration:animations:. What the documentation says about view animations. As the section on Animations in the “View Programming Guide for iOS” says Both UIKit and Core Animation provide support for animations, but the level of support provided by each technology varies. In UIKit, animations are performed using UIView objects … Read more

How to flip an individual UIView (without flipping the parent view)

this code may helps you: put the two views you want to flip inside an unnamed view with the same size and link the IBOutlet UIView *newView,*oldView; to the views and put the new view on top bool a = NO; @implementation ViewController – (IBAction)flip:(id)sender { if (a == NO) { [UIView transitionFromView:oldView toView:newView duration:1.0 … Read more

How can I pop a view from a UINavigationController and replace it with another in one operation?

I’ve discovered you don’t need to manually mess with the viewControllers property at all. Basically there are 2 tricky things about this. self.navigationController will return nil if self is not currently on the navigation controller’s stack. So save it to a local variable before you lose access to it. You must retain (and properly release) … Read more