【问题标题】:UISearchBar background image showing black color on edgesUISearchBar 背景图像在边缘显示黑色
【发布时间】:2015-08-12 18:30:51
【问题描述】:

我正在尝试在 UISearchBar 上应用背景图片。已成功应用,但搜索栏的四个边缘显示黑色。

这是我正在使用的代码:

[_dashboardSearch setSearchFieldBackgroundImage:[UIImage imageNamed:@"search-bar.png"] forState:UIControlStateNormal];
    [_dashboardSearch setBackgroundColor:[UIColor clearColor]];
    [_dashboardSearch setImage:[UIImage imageNamed:@"search_icon.png"] forSearchBarIcon:UISearchBarIconSearch state:UIControlStateNormal];

【问题讨论】:

  • 你可以试试——self.mySearchBar.clipsToBounds = YES;
  • @mKane 这不起作用..
  • 试试 [self.mySearchBar setTintColor:[UIColor clearColor]];
  • 这也行不通

标签: ios iphone uisearchbar


【解决方案1】:

解决了。我在 UISearchBar 中将黑色设置为 UIExfield 背景。下面这行代码写错了:

[(UITextField *)subSubView setBackgroundColor:[UIColor blackColor]];

【讨论】:

    猜你喜欢
    • 2018-03-15
    • 1970-01-01
    • 2022-01-22
    • 1970-01-01
    • 1970-01-01
    • 2020-08-31
    • 1970-01-01
    • 2020-11-15
    • 1970-01-01
    相关资源
    最近更新 更多