【问题标题】:Cursor not displaying in UISearchBar for our app光标未在我们的应用程序的 UISearchBar 中显示
【发布时间】:2013-10-07 18:47:10
【问题描述】:

对于我们应用程序中的 UISearchBars,在 iOS 7 下运行时,焦点栏中没有显示光标。我们如何使其显示?

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

【问题讨论】:

    标签: ios7 uisearchbar uisearchbardisplaycontrol


    【解决方案1】:

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

    【讨论】:

    【解决方案2】:

    设置

    searchBar.tintColor = [UIColor blueColor];
    

    【讨论】:

    • 搜索栏的颜色好像是 (66, 107, 242) fwiw
    【解决方案3】:

    在搜索框属性窗口中

    打开视图部分>设置色调颜色 - 默认。

    希望这会有所帮助。

    【讨论】:

      【解决方案4】:

      这就是在 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()
              }
          }
      
      }
      

      【讨论】:

      • 这是我的 Xamarin C# 端口: UIView view = searchBar.Subviews[0]; foreach (view.Subviews 中的 UIView 项目) { if (item is UITextField) { item.TintColor = UIColor.Blue; } }
      【解决方案5】:
      searchBar.tintColor = view.tintColor  // self.view usually has the proper tintColor
      

      .blue 或其他更好。

      【讨论】:

        【解决方案6】:

        只需在情节提要、xib 或代码中为 UISearchBar 设置 tintColor。 Xcode 似乎忽略了默认的 tintColor。

        【讨论】:

          【解决方案7】:

          您可以遍历 searchBars 子视图并获取 uitextfield 子视图并将其 @"insertionPointColor" 值设置为您想要的颜色。工作,但是私有 api

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

          【讨论】:

            猜你喜欢
            • 2011-08-18
            • 2015-12-01
            • 2015-04-30
            • 1970-01-01
            • 2016-07-20
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            • 1970-01-01
            相关资源
            最近更新 更多