<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "tvOS: -",
    "visionOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "UIKit",
  "identifier" : "/documentation/UIKit/UIAppearance",
  "metadataVersion" : "0.1.0",
  "role" : "Protocol",
  "symbol" : {
    "kind" : "Protocol",
    "modules" : [
      "UIKit"
    ],
    "preciseIdentifier" : "c:objc(pl)UIAppearance"
  },
  "title" : "UIAppearance"
}
-->

# UIAppearance

A collection of methods that gives you access to the appearance proxy for a class.

```
@MainActor protocol UIAppearance : NSObjectProtocol
```

## Overview

You can customize the appearance of instances of a class by sending appearance-modification messages to the class’s appearance proxy.

> Note:
> iOS applies appearance changes when a view enters a window, but it doesn’t change the appearance of a view that’s already in a window. To change the appearance of a view that’s currently in a window, remove the view from the view hierarchy and then put it back.

There are two ways to customize appearance for objects: for all instances, and for instances contained within an instance of a container class.

To customize the appearance of all instances of a class, use [`appearance()`](/documentation/UIKit/UIAppearance/appearance()) to get the appearance proxy for the class. For example, to modify the bar background tint color for all instances of [`UINavigationBar`](/documentation/UIKit/UINavigationBar):

```swift
UINavigationBar.appearance().barTintColor = navBarTintColor
```

To customize the appearances for instances of a class when contained within an instance of a container class, or instances in a hierarchy, use [`appearanceWhenContainedIn:`](/documentation/UIKit/UIAppearance/appearanceWhenContainedIn:) to get the appearance proxy for the class. For example, to modify the appearance of bar buttons, based on the object that contains the navigation bar:

```swift
let navigationBarAppearance =
UINavigationBar.appearance(whenContainedInInstancesOf: [UINavigationController.self])
navigationBarAppearance.setBackgroundImage(navBarBackgroundImage, for: .any, barMetrics: .default)

let barButtonNavigationBarAppearance =
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UINavigationBar.self])
barButtonNavigationBarAppearance.setBackgroundImage(barButtonNavBarImage, for: .normal, barMetrics: .default)

let barButtonToolbarAppearance =
UIBarButtonItem.appearance(whenContainedInInstancesOf: [UIToolbar.self])
barButtonToolbarAppearance.setBackgroundImage(barButtonToolbarImage, for: .normal, barMetrics: .default)
```

In any given view hierarchy, the outermost appearance proxy wins. Specificity (depth of the chain) is the tie-breaker. In other words, the containment statement in [`appearanceWhenContainedIn:`](/documentation/UIKit/UIAppearance/appearanceWhenContainedIn:) is treated as a partial ordering. Given a concrete ordering (actual subview hierarchy), UIKit selects the partial ordering that’s the first unique match when reading the actual hierarchy from the window down.

You can further refine which instances of a class will have their appearance customized by specifying a trait collection. Use the [`appearance(for:)`](/documentation/UIKit/UIAppearance/appearance(for:)) and [`appearanceForTraitCollection:whenContainedIn:`](/documentation/UIKit/UIAppearance/appearanceForTraitCollection:whenContainedIn:) methods to retrieve the proxy for a class with the specified trait collection.

To support appearance customization, a class must conform to the [`UIAppearanceContainer`](/documentation/UIKit/UIAppearanceContainer) protocol and relevant accessor methods must be marked with [`UI_APPEARANCE_SELECTOR`](/documentation/UIKit/UI_APPEARANCE_SELECTOR).

## Topics

### Working with the appearance proxy

[`+  appearance`](/documentation/UIKit/UIAppearance/appearance())

Returns the appearance proxy for the receiver.

[`+  appearanceForTraitCollection:`](/documentation/UIKit/UIAppearance/appearance(for:))

Returns the appearance proxy for the receiver that has the passed trait collection.

[`+  appearanceWhenContainedInInstancesOfClasses:`](/documentation/UIKit/UIAppearance/appearance(whenContainedInInstancesOf:))

Returns the appearance proxy for the object when it’s contained in the hierarchy the specified classes describe.

[`+  appearanceForTraitCollection:whenContainedInInstancesOfClasses:`](/documentation/UIKit/UIAppearance/appearance(for:whenContainedInInstancesOf:))

Returns the appearance proxy for the object when it’s contained in the hierarchy the specified classes describe and has the specified trait collection.

[`+  appearanceWhenContainedIn:`](/documentation/UIKit/UIAppearance/appearanceWhenContainedIn:)

Returns the appearance proxy for object when it’s contained in the hierarchy the specified classes describe.

[`+  appearanceForTraitCollection:whenContainedIn:`](/documentation/UIKit/UIAppearance/appearanceForTraitCollection:whenContainedIn:)

Returns the appearance proxy for the object when it’s contained in the hierarchy the specified classes describe and has the specified trait collection.

## Relationships

### Conforming Types

[`UIStandardTextCursorView`](/documentation/UIKit/UIStandardTextCursorView)

[`UISearchBar`](/documentation/UIKit/UISearchBar)

[`UIInputView`](/documentation/UIKit/UIInputView)

[`UIVisualEffectView`](/documentation/UIKit/UIVisualEffectView)

[`UIWindow`](/documentation/UIKit/UIWindow)

[`UISlider`](/documentation/UIKit/UISlider)

[`UIStepper`](/documentation/UIKit/UIStepper)

[`UIBackgroundExtensionView`](/documentation/UIKit/UIBackgroundExtensionView)

[`UITabBar`](/documentation/UIKit/UITabBar)

[`UIPopoverBackgroundView`](/documentation/UIKit/UIPopoverBackgroundView)

[`UILabel`](/documentation/UIKit/UILabel)

[`UIPageControl`](/documentation/UIKit/UIPageControl)

[`UIImageView`](/documentation/UIKit/UIImageView)

[`UICollectionViewCell`](/documentation/UIKit/UICollectionViewCell)

[`UICollectionViewListCell`](/documentation/UIKit/UICollectionViewListCell)

[`UITextView`](/documentation/UIKit/UITextView)

[`UIControl`](/documentation/UIKit/UIControl)

[`UIBarItem`](/documentation/UIKit/UIBarItem)

[`UITableView`](/documentation/UIKit/UITableView)

[`UIDatePicker`](/documentation/UIKit/UIDatePicker)

[`UISearchTextField`](/documentation/UIKit/UISearchTextField)

[`UIRefreshControl`](/documentation/UIKit/UIRefreshControl)

[`UIBarButtonItem`](/documentation/UIKit/UIBarButtonItem)

[`UIWebView`](/documentation/UIKit/UIWebView)

[`UIScrollView`](/documentation/UIKit/UIScrollView)

[`UITableViewHeaderFooterView`](/documentation/UIKit/UITableViewHeaderFooterView)

[`UIView`](/documentation/UIKit/UIView)

[`UIToolbar`](/documentation/UIKit/UIToolbar)

[`UIListContentView`](/documentation/UIKit/UIListContentView)

[`UISegmentedControl`](/documentation/UIKit/UISegmentedControl)

[`UIEventAttributionView`](/documentation/UIKit/UIEventAttributionView)

[`UISwitch`](/documentation/UIKit/UISwitch)

[`UICollectionView`](/documentation/UIKit/UICollectionView)

[`UIActionSheet`](/documentation/UIKit/UIActionSheet)

[`UICalendarView`](/documentation/UIKit/UICalendarView)

[`UIProgressView`](/documentation/UIKit/UIProgressView)

[`UIPasteControl`](/documentation/UIKit/UIPasteControl)

[`UIContentUnavailableView`](/documentation/UIKit/UIContentUnavailableView)

[`UINavigationBar`](/documentation/UIKit/UINavigationBar)

[`UICollectionReusableView`](/documentation/UIKit/UICollectionReusableView)

[`UIAlertView`](/documentation/UIKit/UIAlertView)

[`UIColorWell`](/documentation/UIKit/UIColorWell)

[`UIStackView`](/documentation/UIKit/UIStackView)

[`UIButton`](/documentation/UIKit/UIButton)

[`UIActivityIndicatorView`](/documentation/UIKit/UIActivityIndicatorView)

[`UITableViewCell`](/documentation/UIKit/UITableViewCell)

[`UITabBarItem`](/documentation/UIKit/UITabBarItem)

[`UIPickerView`](/documentation/UIKit/UIPickerView)

[`UITextField`](/documentation/UIKit/UITextField)

### Inherits From

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

---

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)