So, basically i made a custom cell from a nib, wish i apply a little custom design, like colors and shadows.
I found two ways of applying the styling:
awakeFromNib():
override func awakeFromNib() {
super.awakeFromNib()
//Container Card Style
self.container.layer.cornerRadius = 3
self.container.setDropShadow(UIColor.blackColor(), opacity: 0.20, xOffset: 1.5, yOffset: 2.0, radius: 1.8)
//Rounded thumbnail
self.thumb_image.setRoundedShape()
self.thumb_image.backgroundColor = UIColor.customGreyTableBackground()
//Cell
self.backgroundColor = UIColor.customGreyTableBackground()
self.selectionStyle = .None
}
cellForRowAtIndexPath: (inside the tableView wish will show the cell)
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
//get cell type
let cell = tableView.dequeueReusableCellWithIdentifier("searchResultCell", forIndexPath: indexPath) as! SearchResultCell
//Container Card Style
cell.container.layer.cornerRadius = 3
cell.container.setDropShadow(UIColor.blackColor(), opacity: 0.20, xOffset: 1.5, yOffset: 2.0, radius: 1.8)
//Rounded thumbnail
cell.thumb_image.setRoundedShape()
cell.thumb_image.backgroundColor = UIColor.customGreyTableBackground()
//Cell
cell.backgroundColor = UIColor.customGreyTableBackground()
cell.selectionStyle = .None
//cell data
if(!data.isEmpty){
cell.name_label.text = data[indexPath.row].name
cell.thumb_url = data[indexPath.row].thumb_url
}
return cell
}
In terms of performance, wish one will be better? I've noticed that in a awakeFromNib() the design only does it once, so this is the better one?