UITableViewCell show white background and cannot be modified on iOS7

后端 未结 14 1363
轻奢々
轻奢々 2020-11-28 18:42

I\'ve implemented a custom table view cell class that inherit from UITableViewCell. The tableview contains a background image, so I want cell\'s background to b

14条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-28 18:44

    Had a similar problem, had to

    1. Set blue as the selectionStyle and
    2. add this to the code to correct it

      override func tableView(tableView: UITableView, shouldHighlightRowAtIndexPath indexPath: NSIndexPath) -> Bool {
      
        var bgColorView: UIView = UIView()
        bgColorView.backgroundColor = UIColor(red: (76.0 / 255.0), green: (161.0 / 255.0), blue: (255.0 / 255.0), alpha: 1.0)
        bgColorView.layer.masksToBounds = true
        tableView.cellForRowAtIndexPath(indexPath)!.selectedBackgroundView = bgColorView
        return true
      }
      

提交回复
热议问题