I have a table which has custom cells,
Like the image, I have the background is gray, but my goal is that the gray is in gradients, I mean have a stronger gray from the right to the clear on the left, example image:
so far I have
I leave the class code of the cell:
class PanelHomeTableViewCell: UITableViewCell {
@IBOutlet weak var strLblTitleOptionsMenu: UILabel!
@IBOutlet weak var imgOptionsMenu: UIImageView!
override func awakeFromNib() {
super.awakeFromNib()
// Initialization code
}
override func setSelected(_ selected: Bool, animated: Bool) {
super.setSelected(selected, animated: animated)
// Configure the view for the selected state
}
}
The Method where you set the gray background
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let mainCell = Bundle.main.loadNibNamed("PanelHomeTableViewCell", owner: self, options: nil)?.first as! PanelHomeTableViewCell
mainCell.selectionStyle = .none
// SETEO GRIS ; QUIERO DEGRADES
mainCell.backgroundColor = Utils.Color.COLOR_E8E8E8
mainCell.strLblTitleOptionsMenu.textColor = Utils.Color.COLOR_2B5034
switch (indexPath.section)
{
case 0:
mainCell.strLblTitleOptionsMenu.text=NSLocalizedString("strLblOption1",comment:"")
mainCell.imgOptionsMenu.image = UIImage.init(named:"PagarMenu")
return mainCell
case 1:
mainCell.strLblTitleOptionsMenu.text = NSLocalizedString("strLblOption2",comment:"")
mainCell.imgOptionsMenu.image = UIImage.init(named:"BillingMenu")
return mainCell
case 2:
mainCell.strLblTitleOptionsMenu.text = NSLocalizedString("strLblOption3",comment:"")
mainCell.imgOptionsMenu.image = UIImage.init(named:"CollectionNotificationsMenu")
return mainCell
case 3:
mainCell.strLblTitleOptionsMenu.text = NSLocalizedString("strLblOption4",comment:"")
mainCell.imgOptionsMenu.image = UIImage.init(named:"billingQueryMenu")
return mainCell
case 4:
mainCell.strLblTitleOptionsMenu.text = NSLocalizedString("strLblOption5",comment:"")
mainCell.imgOptionsMenu.image = UIImage.init(named:"MovsBalanceMenu")
return mainCell
case 5:
mainCell.strLblTitleOptionsMenu.text = NSLocalizedString("strLblOption6",comment:"")
mainCell.imgOptionsMenu.image = UIImage.init(named:"CashOutMenu")
return mainCell
default:
break
}
return mainCell
}
I use xcode with swift