<!--
{
  "documentType" : "article",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/choosing-a-user-interface-idiom-for-your-mac-app",
  "metadataVersion" : "0.1.0",
  "role" : "article",
  "title" : "Choosing a user interface idiom for your Mac app"
}
-->

# Choosing a user interface idiom for your Mac app

Select the iPad or the Mac user interface idiom in your Mac app built with Mac Catalyst.

## Discussion

A Mac app built with Mac Catalyst can run in either [`UIUserInterfaceIdiom.pad`](/documentation/UIKit/UIUserInterfaceIdiom/pad) or [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac) user interface idioms. To choose the idiom in which your app runs, select from the following options after you turn on Mac Catalyst in your Xcode project:

- Scale Interface to Match iPad: Run your app in the [`UIUserInterfaceIdiom.pad`](/documentation/UIKit/UIUserInterfaceIdiom/pad) idiom. Select this option to quickly bring your iPad app to the Mac.
- Optimize Interface for Mac: Run your app in the [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac) idiom. Select this option to show controls that look and behave like those available in AppKit.

> Note:
> To learn more about turning on Mac Catalyst in your Xcode project, see <doc://com.apple.uikit/documentation/UIKit/creating-a-mac-version-of-your-ipad-app>.

### Start with the iPad idiom

By default, Xcode selects Scale Interface to Match iPad after you turn on Mac Catalyst. This option provides a simplified approach for bringing your iPad app to the Mac. Your Mac app runs in the [`UIUserInterfaceIdiom.pad`](/documentation/UIKit/UIUserInterfaceIdiom/pad) idiom, which tells macOS to scale the app’s user interface to match the Mac display environment while preserving iPad-like appearance and view metrics.

When testing your app you may find that adopting controls that look and behave like those in AppKit or providing crisper-looking text can enhance the user experience of your app. If this is the case, change to the [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac) by selecting Optimize Interface for Mac. However, selecting this option may require you to make additional changes to your app.

### Update your app to use the Mac idiom

Choosing Optimize Interface for Mac means your Mac app runs in the [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac) user interface idiom, which changes the interface of your app. Some controls change their size and appearance, and interacting with them feels identical to interacting with AppKit controls. For example, [`UIButton`](/documentation/UIKit/UIButton) appears identical to <doc://com.apple.documentation/documentation/AppKit/NSButton>.

Because the system sets control sizes appropriately when the user interface idiom is [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac), the system no longer needs to scale your app’s interface to match Mac sizing. Screen points are identical in size to those in AppKit-based apps. However, if your app has hard-coded sizes or uses images sized for iPad, you may need to update your app to accommodate the size differences. You may also need to adjust auto layout constraints.

Some controls provide additional settings that help you achieve a more Mac-like appearance. For instance, [`UISwitch`](/documentation/UIKit/UISwitch) can appear as a checkbox when idiom is [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac) by setting [`preferredStyle`](/documentation/UIKit/UISwitch/preferredStyle) to [`UISwitch.Style.checkbox`](/documentation/UIKit/UISwitch/Style-swift.enum/checkbox). Then set [`title`](/documentation/UIKit/UISwitch/title) to the text of the checkbox.

```swift
let showFavoritesAtTop = UISwitch()
showFavoritesAtTop.preferredStyle = .checkbox
if traitCollection.userInterfaceIdiom == .mac {
    showFavoritesAtTop.title = "Always show favorite recipes at the top"
}
```

[`UIPageControl`](/documentation/UIKit/UIPageControl) isn’t available to apps running in the Mac idiom. If you attempt to display this control in a view, your app throws an exception. Replace it with similar functionality when the user interface idiom is [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac).

### Determine the current user interface idiom

To determine if your app is running in the Mac idiom, compare the value of the [`userInterfaceIdiom`](/documentation/UIKit/UITraitCollection/userInterfaceIdiom) property with [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac). When the comparison is <doc://com.apple.documentation/documentation/Swift/true>, you can tailor the behavior of your app for the Mac; for example, to display a different child view.

```swift
let childViewController: UIViewController
if traitCollection.userInterfaceIdiom == .mac {
    childViewController = MacOptimizedChildViewController()
} else {
    childViewController = ChildViewController()
}
addChild(childViewController)
childViewController.view.frame = view.bounds
view.addSubview(childViewController.view)
childViewController.didMove(toParent: self)
```

### Set the preferred behavioral style

When adopting the Mac idiom, some controls such as [`UIButton`](/documentation/UIKit/UIButton) and [`UISlider`](/documentation/UIKit/UISlider) appear identical to their AppKit counterparts. However, there may be situations where you want to take advantage of the Mac idiom in your app but keep a control’s iPad appearance and behavior. For instance, consider an iPad app that displays a slider with a custom thumb image. By default, the Mac version of the app, built with Mac Catalyst, displays a standard macOS slider when the user interface idiom is [`UIUserInterfaceIdiom.mac`](/documentation/UIKit/UIUserInterfaceIdiom/mac).

To provide a slider with an appearance that’s consistent in both iPad and Mac versions of the app, set the [`preferredBehavioralStyle`](/documentation/UIKit/UISlider/preferredBehavioralStyle) of the slider to [`UIBehavioralStyle.pad`](/documentation/UIKit/UIBehavioralStyle/pad). This behavioral style tells the slider to behave as if the user interface idiom is [`UIUserInterfaceIdiom.pad`](/documentation/UIKit/UIUserInterfaceIdiom/pad) even though the app is using the Mac idiom.

Remember, macOS doesn’t scale the interface of apps that use the Mac idiom so you may need to update your app to accommodate size differences even when the preferred behavioral style is [`UIBehavioralStyle.pad`](/documentation/UIKit/UIBehavioralStyle/pad). For example, a slider with a custom thumb image may need an image of a different size for the Mac app than the one used in the iPad app.

```swift
let slider = UISlider()
slider.minimumValue = 0
slider.maximumValue = 1
slider.value = 0.5
slider.preferredBehavioralStyle = .pad

if slider.traitCollection.userInterfaceIdiom == .mac {
    slider.setThumbImage(#imageLiteral(resourceName: "customSliderThumbMac"), for: .normal)
} else {
    slider.setThumbImage(#imageLiteral(resourceName: "customSliderThumb"), for: .normal)
}
```

There are some properties and methods of [`UIButton`](/documentation/UIKit/UIButton) and [`UISlider`](/documentation/UIKit/UISlider) not supported in the Mac idiom when the behavioral style is [`UIBehavioralStyle.mac`](/documentation/UIKit/UIBehavioralStyle/mac), and calling these throws an exception; for example, setting a button’s title or image for any control state other than [`normal`](/documentation/UIKit/UIControl/State-swift.struct/normal), and setting a slider’s thumb image, minimum or maximum track image, tint color, or value image. However, these properties and methods are available for use in the Mac idiom when the control’s behavioral style is [`UIBehavioralStyle.pad`](/documentation/UIKit/UIBehavioralStyle/pad).

### Provide a different code path

Even when your Mac app runs in the [`UIUserInterfaceIdiom.pad`](/documentation/UIKit/UIUserInterfaceIdiom/pad) idiom, you may need to change the appearance or behavior of your Mac app. Use the `targetEnvironment()` compilation conditional to choose a different code path depending on the target environment.

For example, if your iPad app displays a delete item confirmation in a popover next to a delete button but you want to display the confirmation as an alert in your Mac app, add a `targetEnvironment()` conditional to determine the preferred style of the alert controller.

```swift
let deleteAction = UIAlertAction(title: "Delete", style: .destructive) { (action) in
    if dataStore.delete(recipe) {
        self.recipe = nil
    }
}

let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)

#if targetEnvironment(macCatalyst)
let preferredStyle = UIAlertController.Style.alert
#else
let preferredStyle = UIAlertController.Style.actionSheet
#endif

let alert = UIAlertController(title: "Are you sure you want to delete \(recipe.title)?", message: nil, preferredStyle: preferredStyle)
alert.addAction(deleteAction)
alert.addAction(cancelAction)

if let popoverPresentationController = alert.popoverPresentationController {
    popoverPresentationController.barButtonItem = sender as? UIBarButtonItem
}

present(alert, animated: true, completion: nil)
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)