我有一个 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/