Ios7 光标未显示在应用程序的UISearchBar中

Ios7 光标未显示在应用程序的UISearchBar中,ios7,uisearchbar,uisearchbardisplaycontrol,Ios7,Uisearchbar,Uisearchbardisplaycontrol,对于我们应用程序中的UISearchBars,当在iOS 7下运行时,在带有焦点的工具栏中没有显示光标。我们怎么做这个节目 我们使用的是SDK 7,最低目标是6。我们确实关闭了导航栏的半透明,并在运行时设置颜色。我想不出我们还有什么不同的做法。我们的问题是色调设置为白色,所以我没有看到它。设置 searchBar.tintColor = [UIColor blueColor]; 只需在故事板、xib或代码中为UISearchBar设置tintColor。Xcode似乎忽略了搜索框属性窗口中的默

对于我们应用程序中的UISearchBars,当在iOS 7下运行时,在带有焦点的工具栏中没有显示光标。我们怎么做这个节目


我们使用的是SDK 7,最低目标是6。我们确实关闭了导航栏的半透明,并在运行时设置颜色。我想不出我们还有什么不同的做法。

我们的问题是色调设置为白色,所以我没有看到它。

设置

searchBar.tintColor = [UIColor blueColor];

只需在故事板、xib或代码中为UISearchBar设置tintColor。Xcode似乎忽略了搜索框属性窗口中的默认颜色。

打开视图部分>设置着色颜色-默认值


希望这会有所帮助。

您可以循环搜索栏子视图,获取uitextfield子视图,并将其@“insertionPointColor”值设置为所需的颜色。可以工作,但它是私有api

for (UIView *subView in self.searchBar.subviews) {
    if ([subView isKindOfClass:[UITextField class]]) {
        [[(UITextField *) subView valueForKey:@"textInputTraits"] setValue:[UIColor blackColor] forKey:@"insertionPointColor"];
    }
}

以下是在Swift中实现的方法:

override func viewWillAppear(animated: Bool) {
    self.searchBar.tintColor = UIColor.whiteColor()

    let view: UIView = self.searchBar.subviews[0] as! UIView
    let subViewsArray = view.subviews

    for (subView: UIView) in subViewsArray as! [UIView] {
        println(subView)
        if subView.isKindOfClass(UITextField){
            subView.tintColor = UIColor.blueColor()
        }
    }

}

.blue
或其他任何东西更好。

搜索栏的颜色似乎是(66107242)fwiwHere是我的Xamarin C#port:UIView view=searchBar.subview[0];foreach(UIView-item-in-view.subview){if(item-is-UITextField){item.TintColor=UIColor.Blue;}}}如果希望光标的颜色与按钮的颜色不同:相同的问题。。谢谢
searchBar.tintColor = view.tintColor  // self.view usually has the proper tintColor