小编use*_*325的帖子

Xamarin iOS隐藏搜索栏中的取消按钮

我想在iOS搜索栏中隐藏“取消”按钮。我已经实现了以下自定义渲染器代码,但似乎无法正常工作。如果有人知道解决方案,请分享。

public class iOSSearchBar : SearchBarRenderer 
    {
        protected override void OnElementChanged(ElementChangedEventArgs<SearchBar> args)
        {
            base.OnElementChanged(args);

        UISearchBar bar = (UISearchBar)this.Control;

        bar.AutocapitalizationType = UITextAutocapitalizationType.None;
        bar.AutocorrectionType = UITextAutocorrectionType.No;
        //bar.BarStyle = UIBarStyle.Default;
        //bar.BarTintColor = UIColor.LightGray;
        //bar.KeyboardType = UIKeyboardType.ASCIICapable;
        bar.SearchBarStyle = UISearchBarStyle.Minimal;
        bar.SetShowsCancelButton(false, false);
        bar.ShowsCancelButton = false;
}
}
Run Code Online (Sandbox Code Playgroud)

提前致谢

uisearchbar xamarin.ios ios xamarin

4
推荐指数
2
解决办法
2567
查看次数

标签 统计

ios ×1

uisearchbar ×1

xamarin ×1

xamarin.ios ×1