【问题标题】:UISearchBar set as titleView acts weird on push segueUISearchBar 设置为 titleView 在 push segue 上的行为很奇怪
【发布时间】:2015-01-30 23:56:24
【问题描述】:

我将 UISearchBar 设置为导航栏的 titleView。当我将 segue 推到下一个视图控制器时,它会正确地向左消失。但是,当回击并返回到原始视图时,它会尝试对其进行动画处理并且看起来很糟糕。

这是我回击时发生的动画截图。

我不确定如何摆脱这个...有什么想法吗?

编辑:我认为这可能与搜索栏的背景图片有关。

【问题讨论】:

  • 我刚试过,看起来很完美没问题,你能告诉我们你的代码吗?
  • 我刚刚修好了!还是谢谢。

标签: ios swift uisearchbar segue


【解决方案1】:

这以某种方式修复了它。

searchBar.backgroundImage = getImageWithColor(blue, size: CGSize(width: 100, height: 50))

func getImageWithColor(color: UIColor, size: CGSize) -> UIImage {
    var rect = CGRectMake(0, 0, size.width, size.height)
    UIGraphicsBeginImageContextWithOptions(size, false, 0)
    color.setFill()
    UIRectFill(rect)
    var image: UIImage = UIGraphicsGetImageFromCurrentImageContext()
    UIGraphicsEndImageContext()
    return image
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-03-14
    • 1970-01-01
    • 2015-10-17
    • 2019-01-23
    • 2013-08-01
    相关资源
    最近更新 更多