---
title: "willAnimateRotation(to:duration:)"
framework: uikit
role: symbol
role_heading: Instance Method
path: "uikit/uiviewcontroller/willanimaterotation(to:duration:)"
---

# willAnimateRotation(to:duration:)

Sent to the view controller before performing a one-step user interface rotation.

## Declaration

```swift
func willAnimateRotation(to toInterfaceOrientation: UIInterfaceOrientation, duration: TimeInterval)
```

## Parameters

- `toInterfaceOrientation`: The new orientation for the user interface. The possible values are described in doc://com.apple.uikit/documentation/UIKit/UIInterfaceOrientation.
- `duration`: The duration of the pending rotation, measured in seconds.

## Discussion

Discussion This method is called from within the animation block used to rotate the view. You can override this method and use it to configure additional animations that should occur during the view rotation. For example, you could use it to adjust the zoom level of your content, change the scroller position, or modify other animatable properties of your view. note: The animations used to slide the header and footer views in and out of position are performed in separate animation blocks. By the time this method is called, the interfaceOrientation property is already set to the new orientation, and the bounds of the view have been changed. Thus, you can perform any additional layout required by your views in this method.

## See Also

### Deprecated methods

- [setOverrideTraitCollection(_:forChild:)](uikit/uiviewcontroller/setoverridetraitcollection(_:forchild:).md)
- [overrideTraitCollection(forChild:)](uikit/uiviewcontroller/overridetraitcollection(forchild:).md)
- [attemptRotationToDeviceOrientation()](uikit/uiviewcontroller/attemptrotationtodeviceorientation().md)
- [registerForPreviewing(with:sourceView:)](uikit/uiviewcontroller/registerforpreviewing(with:sourceview:).md)
- [unregisterForPreviewing(withContext:)](uikit/uiviewcontroller/unregisterforpreviewing(withcontext:).md)
- [canPerformUnwindSegueAction(_:from:withSender:)](uikit/uiviewcontroller/canperformunwindsegueaction(_:from:withsender:).md)
- [didRotate(from:)](uikit/uiviewcontroller/didrotate(from:).md)
- [dismissMoviePlayerViewControllerAnimated()](uikit/uiviewcontroller/dismissmovieplayerviewcontrolleranimated().md)
- [forUnwindSegueAction(_:from:withSender:)](uikit/uiviewcontroller/forunwindsegueaction(_:from:withsender:).md)
- [presentMoviePlayerViewControllerAnimated(_:)](uikit/uiviewcontroller/presentmovieplayerviewcontrolleranimated(_:).md)
- [rotatingFooterView()](uikit/uiviewcontroller/rotatingfooterview().md)
- [rotatingHeaderView()](uikit/uiviewcontroller/rotatingheaderview().md)
- [segueForUnwinding(to:from:identifier:)](uikit/uiviewcontroller/segueforunwinding(to:from:identifier:).md)
- [shouldAutomaticallyForwardRotationMethods()](uikit/uiviewcontroller/shouldautomaticallyforwardrotationmethods().md)
- [willRotate(to:duration:)](uikit/uiviewcontroller/willrotate(to:duration:).md)
