全局

最近更新时间:2025-05-23 10:46:52

我的收藏
下文将向您展示如何设置全局自定义选项及其效果。

切换 TUIKit 语言

API 作用:切换 TUIKit 语言。
方法原型:
Swift
Objective-C
// TUIConfig_Classic.swift
/**
* Switch the language of TUIKit.
* The currently supported languages are "en", "zh-Hans", and "ar".
*/
static func switchLanguage(to targetLanguage: String) {
TUIGlobalization.setPreferredLanguage(targetLanguage)
}
// TUIConfig_Classic.h
/**
* Switch the language of TUIKit.
* The currently supported languages are "en", "zh-Hans", and "ar".
*/
+ (void)switchLanguageToTarget:(NSString *)targetLanguage;
示例代码:
Swift
Objective-C
// When to call: Before initializing the TUIKit interface.
TUIConfig_Classic.switchLanguage(to: "en")
// When to call: Before initializing the TUIKit interface.
[TUIConfig_Classic switchLanguageToTarget:@"en"];
设置效果:
设置为英文
设置为阿拉伯语







切换 TUIKit 主题

API 作用:切换 TUIKit 主题。
方法原型:
Swift
Objective-C
/**
* Switch the theme of TUIKit.
* The currently supported themes are "system", "serious", "light", "lively", "dark"
*/
static func switchTheme(to targetTheme: String) {
TUIThemeManager.share().applyTheme(targetTheme, for: TUIThemeModule.all)
}
/**
* Switch the theme of TUIKit.
* The currently supported themes are "system", "serious", "light", "lively", "dark"
*/
+ (void)switchThemeToTarget:(NSString *)targetTheme;
示例代码:
Swift
Objective-C
// When to call: Before initializing the TUIKit interface.
TUIConfig_Classic.switchTheme(to: "light")
// When to call: Before initializing the TUIKit interface.
[TUIConfig_Classic switchThemeToTarget:@"light"];
设置效果:
设置为 lively 主题
设置为 dark 主题
设置为 serious 主题
默认 light 主题













开启 TUIKit 内建提示

API 作用:设置是否开启 TUIKit 内建 toast 提示。默认开启,TUIKit 组件会显示内建的提示。
方法原型:
Swift
Objective-C
/**
* Show the toast prompt built in TUIKit.
* The default value is YES.
*/
static func enableToast(_ enable: Bool) {
TUIConfig.default().enableToast = enable
}
// TUIConfig_Classic.h
/**
* Show the toast prompt built in TUIKit.
* The default value is YES.
*/
+ (void)enableToast:(BOOL)enable;
示例代码:
Swift
Objective-C
// When to call: Before initializing the TUIKit interface.
TUIConfig_Classic.enableToast(false)
// When to call: Before initializing the TUIKit interface.
[TUIConfig_Classic enableToast:NO];
设置效果:
开启 Toast 提示
关闭 Toast 提示