I have a multiplier constraint setup for a field label and the field value within a table cell. See attached screenshot. I want to conditionally modify the constraint based on the field label. So the field value will have more width as needed. Any suggestions would be appreciated.
I'm using a switch statement to setup the field label and value. see below.
switch indexPath.row {
case 0:
cell.fieldLabel.text = "Program: "
cell.valueLabel.text = services.name
cell.fieldLabel.font = UIFont(name: "Avenir-Medium", size: 14.0)
cell.fieldLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
cell.valueLabel.font = UIFont(name: "Avenir-Heavy", size: 20.0)
cell.valueLabel.textColor = UIColor(red: 164.0/255.0, green: 45.0/255.0, blue: 9.0/255.0, alpha: 1.0)
case 1:
cell.fieldLabel.text = "Branch: "
cell.valueLabel.text = services.branch
cell.fieldLabel.font = UIFont(name: "Avenir-Medium", size: 14.0)
cell.fieldLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
cell.valueLabel.font = UIFont(name: "Avenir-Light", size: 16.0)
cell.valueLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
case 2:
cell.fieldLabel.text = "Phone: "
cell.valueLabel.text = services.mainPhone
cell.fieldLabel.font = UIFont(name: "Avenir-Medium", size: 14.0)
cell.fieldLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
cell.valueLabel.font = UIFont(name: "Avenir-Light", size: 16.0)
cell.valueLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
case 3:
cell.fieldLabel.text = "Locations: "
cell.valueLabel.text = services.locations
cell.fieldLabel.font = UIFont(name: "Avenir-Medium", size: 14.0)
cell.fieldLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
cell.valueLabel.font = UIFont(name: "Avenir-Light", size: 16.0)
cell.valueLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
cell.accessoryType = .disclosureIndicator
case 4:
cell.fieldLabel.text = "Hours: "
cell.valueLabel.text = services.hours
cell.fieldLabel.font = UIFont(name: "Avenir-Medium", size: 14.0)
cell.fieldLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
cell.valueLabel.font = UIFont(name: "Avenir-Light", size: 16.0)
cell.valueLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
case 5:
cell.fieldLabel.text = "Website: "
cell.valueLabel.text = services.website
cell.fieldLabel.font = UIFont(name: "Avenir-Medium", size: 14.0)
cell.fieldLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
cell.valueLabel.font = UIFont(name: "Avenir-Light", size: 16.0)
cell.valueLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
case 6:
cell.fieldLabel.text = " "
cell.valueLabel.text = services.longDesc
cell.fieldLabel.font = UIFont(name: "Avenir-Medium", size: 14.0)
cell.fieldLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
cell.valueLabel.font = UIFont(name: "Avenir-Light", size: 16.0)
cell.valueLabel.textColor = UIColor(red: 0.0/255.0, green: 0.0/255.0, blue: 0.0/255.0, alpha: 1.0)
default:
cell.fieldLabel.text = ""
cell.valueLabel.text = ""
}