---
title: UIViewRepresentable
framework: swiftui
role: symbol
role_heading: Protocol
path: swiftui/uiviewrepresentable
---

# UIViewRepresentable

A wrapper for a UIKit view that you use to integrate that view into your SwiftUI view hierarchy.

## Declaration

```swift
@MainActor @preconcurrency protocol UIViewRepresentable : View where Self.Body == Never
```

## Overview

Overview Use a UIViewRepresentable instance to create and manage a UIView object in your SwiftUI interface. Adopt this protocol in one of your app’s custom instances, and use its methods to create, update, and tear down your view. The creation and update processes parallel the behavior of SwiftUI views, and you use them to configure your view with your app’s current state information. Use the teardown process to remove your view cleanly from your SwiftUI. For example, you might use the teardown process to notify other objects that the view is disappearing. To add your view into your SwiftUI interface, create your UIViewRepresentable instance and add it to your SwiftUI interface. The system calls the methods of your representable instance at appropriate times to create and update the view. The following example shows the inclusion of a custom MyRepresentedCustomView structure in the view hierarchy. struct ContentView: View {    var body: some View {       VStack {          Text("Global Sales")          MyRepresentedCustomView()       }    } } The system doesn’t automatically communicate changes occurring within your view to other parts of your SwiftUI interface. When you want your view to coordinate with other SwiftUI views, you must provide a Coordinator instance to facilitate those interactions. For example, you use a coordinator to forward target-action and delegate messages from your view to any SwiftUI views. warning: SwiftUI fully controls the layout of the UIKit view’s center, bounds, frame, and transform properties. Don’t directly set these layout-related properties on the view managed by a UIViewRepresentable instance from your own code because that conflicts with SwiftUI and results in undefined behavior.

## Topics

### Creating and updating the view

- [makeUIView(context:)](swiftui/uiviewrepresentable/makeuiview(context:).md)
- [updateUIView(_:context:)](swiftui/uiviewrepresentable/updateuiview(_:context:).md)
- [UIViewRepresentable.Context](swiftui/uiviewrepresentable/context.md)
- [UIViewType](swiftui/uiviewrepresentable/uiviewtype.md)

### Specifying a size

- [sizeThatFits(_:uiView:context:)](swiftui/uiviewrepresentable/sizethatfits(_:uiview:context:).md)

### Cleaning up the view

- [dismantleUIView(_:coordinator:)](swiftui/uiviewrepresentable/dismantleuiview(_:coordinator:).md)

### Providing a custom coordinator object

- [makeCoordinator()](swiftui/uiviewrepresentable/makecoordinator().md)
- [Coordinator](swiftui/uiviewrepresentable/coordinator.md)

### Performing layout

- [UIViewRepresentable.LayoutOptions](swiftui/uiviewrepresentable/layoutoptions.md)

## Relationships

### Inherits From

- [View](swiftui/view.md)

## See Also

### Adding UIKit views to SwiftUI view hierarchies

- [UIViewRepresentableContext](swiftui/uiviewrepresentablecontext.md)
- [UIViewControllerRepresentable](swiftui/uiviewcontrollerrepresentable.md)
- [UIViewControllerRepresentableContext](swiftui/uiviewcontrollerrepresentablecontext.md)
