Skip to content

UISearchBar

UISearchBar 继承自 UIView,用于输入搜索文本与可选范围(scope)筛选。插件运行时通常通过 delegate 获取文本变化/按钮点击等回调(delegate 的具体回调方法名取决于运行时实现与你的对象定义)。

属性类型说明
textstring搜索文本。
placeholderstring | null占位文本。
promptstring | null提示文案。
delegateid代理对象。
showsCancelButtonboolean是否显示取消按钮。
showsBookmarkButtonboolean是否显示书签按钮。
showsSearchResultsButtonboolean是否显示搜索结果按钮。
searchResultsButtonSelectedboolean搜索结果按钮是否选中。
selectedScopeButtonIndexnumber当前选中的 scope 索引。
scopeButtonTitlesNSArrayscope 按钮标题数组。
showsScopeBarboolean是否显示 scope 条。
keyboardTypenumber键盘类型。
autocorrectionTypenumber自动纠错类型。
autocapitalizationTypenumber自动大写类型。
translucentboolean是否半透明。
barTintColorUIColor | nullbar 背景色。
barStylenumberbar 样式。
backgroundImageUIImage | null背景图。
scopeBarBackgroundImageUIImage | nullscope 条背景图。
searchFieldBackgroundPositionAdjustmentobject搜索框背景位置微调。
searchTextPositionAdjustmentobject搜索文字位置微调。
方法参数返回值说明
setShowsCancelButtonAnimated(showsCancelButton, animated)showsCancelButton: boolean, animated: booleanvoid设置取消按钮显示(可动画)。
setSearchFieldBackgroundImageForState(backgroundImage, state)backgroundImage: UIImage, state: numbervoid设置搜索框背景图。
searchFieldBackgroundImageForState(state)state: numberUIImage | null获取搜索框背景图。
setScopeBarButtonBackgroundImageForState(backgroundImage, state)backgroundImage: UIImage, state: numbervoid设置 scope 按钮背景图。
scopeBarButtonBackgroundImageForState(state)state: numberUIImage | null获取 scope 按钮背景图。
setScopeBarButtonDividerImageForLeftSegmentStateRightSegmentState(dividerImage, leftState, rightState)dividerImage: UIImage, leftState: number, rightState: numbervoid设置 scope 分割线图。
scopeBarButtonDividerImageForLeftSegmentStateRightSegmentState(leftState, rightState)leftState: number, rightState: numberUIImage | null获取 scope 分割线图。
setScopeBarButtonTitleTextAttributesForState(attributes, state)attributes: NSDictionary, state: numbervoid设置 scope 标题文字属性。
scopeBarButtonTitleTextAttributesForState(state)state: numberNSDictionary | null获取 scope 标题文字属性。

当前运行时未额外暴露 UISearchBar 的类成员。

头文件 API 清单

正在加载…

协议:,来源: