---
sourceDocument: オーストラリア API リファレンス
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ja-JP/api-reference

 Release :

    - australia

ft:locale :

    - ja-JP

ft:publication_title :

    - オーストラリア API リファレンス

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# NowWebThemeable プロトコル : iOS

# NowWebThemeable プロトコル : iOS {#ariaid-title1}

* リリースバージョン: Australia
* 
* 更新日 2026年03月12日
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 所要時間：6分

NowWebThemeable プロトコルには、ネイティブ Web ビューの ServiceNow インスタンスでホストされている Web ページ内で使用される色を上書きできるプロパティが用意されています。

    public protocol NowWebThemeable {
        var color: NowWebColoring { get }
    }

[NowWebColoring](https://servicenow-prod.fluidtopics.net/TkY25fhglfLRshnXL3g3AA "NowWebColoring プロトコルは、ネイティブ Web ビューの ServiceNow インスタンスでホストされている Web ページ内で使用される色のデフォルト値を提供します。") プロトコルにはNowUIColoringが含まれています。このプロパティは、 NowWebThemeable が使用できるデフォルトの色変数を参照するために使用されます。

UI のテーマを設定する方法の詳細については、『Mobile SDK 開発者ガイド - iOS』の [NowUIColoring を使用して NowWebTheme と NowChatTheme をテーマにする](https://servicenow-prod.fluidtopics.net/FdKC2mClTXwAuvOYp5xcSg "NowUIColoring インターフェイスには、すべての NowSDK モジュールで使用されるすべての色が含まれています。") を参照してください。

## デフォルトの色を使用して WebColor を定義 {#NowWebThemeableiOSProtocol__section_gkf_b13_tzb}

    /// Sample structure for using default colors that come with Mobile SDK.
    struct WebColors: NowUIColoring {
    }

## カスタム色を使用して WebColor を定義 {#NowWebThemeableiOSProtocol__section_ofb_j13_tzb}

    /// Use custom colors with light theme
    struct WebColors: NowUIColoring {
        private var defaultTheme: NowWebDefaultTheme { NowWebDefaultTheme(nowUITheme: NowUIDefaultTheme())
        }
        
        var brand: UIColor { lightBrand }
        var primary: UIColor { lightPrimary }
        var textPrimary: UIColor { lightTextPrimary }
        var screenHeaderText: UIColor { lightScreenHeaderText }
        var screenHeaderBackground: UIColor { lightScreenHeaderBackground }
        var textActionable: UIColor { lightTextActionable }
        var alertCritical0: UIColor { lightAlertCritical0 }
        var alertCritical3: UIColor { lightAlertCritical3 }
        var alertPositive0: UIColor { lightAlertPositive0 }
        var alertPositive3: UIColor { lightAlertPositive3 }
        var alertLow0: UIColor { lightAlertLow0 }
        var alertWarning0: UIColor { lightAlertWarning0 }
        var backgroundPrimary: UIColor { lightBackgroundPrimary }
        
        // Light Colors
        var lightBrand: UIColor { defaultTheme.color.brand }
        var lightPrimary: UIColor { defaultTheme.color.primary }
        var lightTextPrimary: UIColor { defaultTheme.color.textPrimary }
        var lightScreenHeaderText: UIColor { defaultTheme.color.screenHeaderText }
        var lightScreenHeaderBackground: UIColor { defaultTheme.color.screenHeaderBackground }
        var lightTextActionable: UIColor { defaultTheme.color.textActionble }
        var lightAlertCritical0: UIColor { defaultTheme.color.alertCritical0 }
        var lightAlertCritical3: UIColor { defaultTheme.color.alertCritical3 }
        var lightAlertPositive0: UIColor { defaultTheme.color.alertPositive0 }
        var lightAlertPositive3: UIColor { defaultTheme.color.alertPositive3 }
        var lightAlertLow0: UIColor { defaultTheme.color.alertLow0 }
        var lightAlertWarning0: UIColor { defaultTheme.color.alertWarning0 }
        var lightBackgroundPrimary: UIColor { defaultTheme.color.backgroundPrimary }
    }

## NowWebThemeable プロトコルを使用した WebTheme 構造の定義 {#NowWebThemeableiOSProtocol__section_kql_n13_tzb}

    struct CarrascoWebTheme: NowWebThemeable {
        var color: NowWebColoring
        
        struct Color: NowWebColoring {
            var nowUIColor: NowUIColoring
        
            var alertPositive0: UIColor
            var alertPositive3: UIColor
            var alertLow0: UIColor
            var alertWarning0: UIColor
            var backgroundPrimary: UIColor
            
            init(inputs: WebColors) {
                nowUIColor = ThemeColor(inputs)
                
                alertPositive0 = inputs.alertPositive0
                alertPositive3 = inputs.alertPositive3
                alertLow0 = inputs.alertLow0
                alertWarning0 = inputs.alertWarning0
                backgroundPrimary = inputs.backgroundPrimary
            }
        }
        
        public init(webColors: WebColors) {
            color = Color(inputs: webColors)
        }
    }

## WebColor を入力として渡して WebTheme オブジェクトをインスタンス化する {#NowWebThemeableiOSProtocol__section_k4j_t13_tzb}

    let webTheme = CarrascoWebTheme(webColors: WebColors())

## WebTheme オブジェクトを NowWebService.makeWebViewController に渡す {#NowWebThemeableiOSProtocol__section_mzl_w13_tzb}

    func webViewController(for url: URL, delegate: NowWebViewControllerDelegate) -> NowWebViewController? {
      guard let webService = webService else {
        debugPrint("Web service not initialized")
        return nil
      }
      let result = webService.makeWebViewController(for: url, delegate: delegate, theme: CarrascoWebTheme(webColors: WebColors()) )
        
      switch result {
      case .success(let viewController):
        return viewController
      case .failure(let error):
        debugPrint("Web view creation failed with error: \(error.localizedDescription)")
      }
      return nil
    }


