UITableView上的模糊和活力效果

Kot*_*ora 2 ios swift alamofire

我只是不知道该怎么做.我已经尝试了Stackoverflow的所有功能,但没有任何效果.我有一个视图,图像和我的层次结构中的所有tableView.但是桌面视图仍然是白色的.有人知道怎么做吗?正如我所写,这里没有任何工作.

我想要这种UITableView:

UITableView的

导航栏也是我的问题的一部分(他的模糊和活力).

使用此代码后:

func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    var cell:UITableViewCell = self.tableView.dequeueReusableCellWithIdentifier("cell") as UITableViewCell

    let backgroundImageView = UIImageView(image: UIImage(named: "background3.png"))

    cell.backgroundView = backgroundImageView

    var visualEffectView = UIVisualEffectView(effect: UIBlurEffect(style: .Light)) as UIVisualEffectView

    visualEffectView.frame = CGRectMake(0, 0, cell.bounds.width, cell.bounds.height)

    backgroundImageView.addSubview(visualEffectView)

    cell.textLabel?.text = self.field[indexPath.row]
    cell.textLabel?.textColor = UIColor.whiteColor()
    cell.textLabel?.backgroundColor = UIColor.clearColor()

    return cell
}
Run Code Online (Sandbox Code Playgroud)

我的tableView现在看起来像这样:

模拟器截图

这是合乎逻辑的,因为它是background3.png图像的外观.

小智 9

子类UITableViewController.

let effect = UIBlurEffect(style: .Dark)
let resizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight
Run Code Online (Sandbox Code Playgroud)

构建这样的背景视图并将其粘贴到表视图中.注意分隔符效果,这是新的API.

override func viewDidLoad() {
super.viewDidLoad()

let backgroundView = UIView(frame: view.bounds)
backgroundView.autoresizingMask = resizingMask
backgroundView.addSubview(self.buildImageView())
backgroundView.addSubview(self.buildBlurView())

tableView.backgroundView = backgroundView
tableView.separatorEffect = UIVibrancyEffect(forBlurEffect: effect)
}

func buildImageView() -> UIImageView {
let imageView = UIImageView(image: UIImage(named: "coolimage"))
imageView.frame = view.bounds
imageView.autoresizingMask = resizingMask
return imageView
}

func buildBlurView() -> UIVisualEffectView {
let blurView = UIVisualEffectView(effect: effect)
blurView.frame = view.bounds
blurView.autoresizingMask = resizingMask
return blurView
}
Run Code Online (Sandbox Code Playgroud)

更改单元格的背景颜色以清除,因此当您有单元格时背景可见.

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cell", forIndexPath: indexPath)as! UITableViewCell
cell.backgroundColor = UIColor.clearColor()
return cell
}
Run Code Online (Sandbox Code Playgroud)