UITableView cell with background image

后端 未结 9 759
無奈伤痛
無奈伤痛 2020-11-29 17:14

i have a UITableView, where theres 3 images. 1 for the selected Cell, 1 for the Cell background, and 1 for the TableView background.

My selected Cell, is working jus

相关标签:
9条回答
  • 2020-11-29 18:07

    In Swift 4, this works:

    cell.backgroundView = UIImageView.init(image: UIImage.init(named: "YORIMAGE.jpg"))
    
    0 讨论(0)
  • 2020-11-29 18:09

    In swift you can set background image to UITableViewCell like below.

    cell.backgroundView = UIImageView(image: UIImage(named: "yourImage.png")!)
    

    Write this code in this function of table view.

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

    This image will repeat fort each row.

    0 讨论(0)
  • 2020-11-29 18:11

    this sets the background for the tableView not the cell

    // CELL'S BACKGROUND-IMAGE
        self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_normal.PNG"]];
    

    try get set cellbackground in cellForRowAtIndexPath

     cell.backgroundColor =  [UIColor colorWithPatternImage:[UIImage imageNamed:@"cell_normal.PNG"]];
    
    0 讨论(0)
提交回复
热议问题