In my UITableViewCell's content view I have a label that I want to set the frame of programmatically, but it just stays the same no matter what frame I give it. My cellForRowAtIndexPath
-function looks like this:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
let selectedBackground = UIView(frame: CGRectMake(0, 0, width, 44))
let selectedBackgroundImage = UIImageView(frame: CGRectMake(width - 20, 44/2 - 5, 10, 10))
selectedBackgroundImage.image = UIImage(named: "checked")
selectedBackgroundImage.contentMode = .ScaleAspectFit
selectedBackground.addSubview(selectedBackgroundImage)
let separatorViewRegular:UIView = UIView(frame: CGRectMake(0, 43, 1024, 1))
separatorViewRegular.layer.borderColor = grayColor.CGColor
separatorViewRegular.layer.borderWidth = 1
let cell:CompanyTableViewCell = self.companiesTV.dequeueReusableCellWithIdentifier("cell") as! CompanyTableViewCell
cell.label.textColor = UIColor(red: 100/255, green: 100/255, blue: 100/255, alpha: 1)
cell.label.frame = CGRectMake(0.7 * width, 0, 0.3 * width, 44)
cell.label.font = UIFont(name: "Avenir", size: 16)
cell.label.adjustsFontSizeToFitWidth = true
cell.label.numberOfLines = 1
cell.label.textAlignment = NSTextAlignment.Left
cell.backgroundColor = UIColor.clearColor()
cell.label.text = tickersToDisplay[indexPath.row]
cell.selectedBackgroundView = selectedBackground
cell.contentView.addSubview(separatorViewRegular)
return cell
}
Any help and suggestion on why this doesn't work would be appreciated.