[swift] UITableView单元格背景透明问题

来源:互联网 发布:linux运行程序命令gcc 编辑:程序博客网 时间:2024/05/18 04:33

ios7之后UITableViewCell背景无法设置透明了,所以无法看到tableview之下UIImageView上的图片,所以只写这样的代码无效

          var imageView =UIImageView(image: UIImage(named: "background.jpeg"))

         self.view.addSubview(imageView)

        

          self.tableView =UITableView(frame: self.view!.frame)

         self.tableView.delegate =self

         self.tableView.dataSource =self

          self.tableView.backgroundColor =UIColor.clearColor()


          self.view.addSubview(self.tableView)



所以要实现UITableViewDelegate中的方法

         func tableView(tableView:UITableView!, willDisplayCell cell: UITableViewCell!, forRowAtIndexPath indexPath: NSIndexPath!)

         {cell.backgroundColor =UIColor.clearColor()}


即可实现这样的效果





0 0