ios - 让tableView子View随着tableView滚动

标签 ios swift uitableview swift2

我有一个 imageView 作为 tableView 的 subview ,即使 tableView 向下滚动,我也希望它始终位于 tableView 的背景中。我现在的方式是,我假设因为 imageView 框架固定到 tableView 框架,当我向下滚动 tableView 时,就会到达图像的末尾,它只显示 tableView 的背景颜色。

我的代码:

        let imageView: UIImageView = UIImageView(image: background)
        imageView.frame = CGRectMake(0, 0, view.bounds.width, view.bounds.height)
        let darkBlur = UIBlurEffect(style: UIBlurEffectStyle.Dark)
        let blurView = UIVisualEffectView(effect: darkBlur)
        blurView.frame = imageView.frame
        imageView.addSubview(blurView)
        self.tableView.insertSubview(imageView, atIndex: 0)

最佳答案

应该是这样的

self.tableView.backgroundColor = UIColor(patternImage: UIImage(named: "backgroundImage.png")!)

关于ios - 让tableView子View随着tableView滚动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34407715/

相关文章:

ios - 不同的 UITableViewCell 类型对齐

ios - UItableview indexPathForCell - iOS6 'v' iOS7

ios - iCloud Key-Value-Store 同步问题(未调用 NSUbiquitousKeyValueStoreDidChangeExternallyNotification)

ios - 正在输出相同的自定义单元格(Swift)

ios - 当 "draw"被 UIKit 调用时?

ios - 如何调整表格 View 的大小,如果有任何数据并且表格 View 中没有数据

ios - Swift:拉动刷新太敏感

ios - Swift 中的 NSUserDefaults 选项

objective-c - 这是传递 ManagedObjectContext 的可接受方式吗?

ios - 将多个媒体项目排队