ENSwiftSideMenu icon indicating copy to clipboard operation
ENSwiftSideMenu copied to clipboard

Icons for each UITableCellView.

Open datomnurdin opened this issue 10 years ago • 1 comments

Is it possible to place icons on left text on each UITableCellView?

datomnurdin avatar Sep 04 '15 09:09 datomnurdin

Yeah, it is.

In the sample demo, you'll find the below code where the cells are being instantiated. Add the two lines to place icons.

override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

    var cell = tableView.dequeueReusableCellWithIdentifier("CELL")

    if (cell == nil) {

        cell = UITableViewCell(style: UITableViewCellStyle.Default, reuseIdentifier: cellIdentifier)
        cell!.backgroundColor = UIColor.clearColor()
        cell!.textLabel?.textColor = UIColor.whiteColor()
        let selectedBackgroundView = UIView(frame: CGRectMake(0, 0, cell!.frame.size.width, cell!.frame.size.height))
        selectedBackgroundView.backgroundColor = UIColor.grayColor().colorWithAlphaComponent(0.2)
        cell!.selectedBackgroundView = selectedBackgroundView

    }

        // Image for the cell ----> ADD THESE TWO LINES
        let placeholderImage = UIImage(named: "sampleImage")! //sampleImage is the name of the image asset. Replace with your image.
        cell!.imageView?.image = placeholderImage

        // Text for the cell
        cell!.textLabel?.text = "Text"

    return cell!

}

eanvith avatar Dec 13 '15 16:12 eanvith