AbaEesa
AbaEesa

Reputation: 998

Change image size of cell image in static table

enter image description here

I've created this entire menu using the static table, no code so far for this. But I want to manipulate 2 things.

  1. I want to control image height & width present in each cell. As shown above.
  2. Need to change x position of "Accessory" present in every cell.(Refer reference image 2)

enter image description here

As you can see the menu is hiding all my accessories. Reducing TableView width would make another issue of the black bar as shown in below image.

enter image description here

Storyboard approach is appreciated. Or few lines of code. But don't recommend me to make entire TableView using code.

Employing custom cell you can solve the problem, but you have to create image, label & accessory, which were given complimentary with default cell. So if it is not possible then prove it otherwise provide a solution.

Upvotes: 0

Views: 126

Answers (1)

Anbu.Karthik
Anbu.Karthik

Reputation: 82759

Q1: I want to control image height & width

A: Initially check your tableviewCell type as Custom or not, if its not custom change the cell type to custom, and you want the fixed width and height then change the following lines in storyboard

    imageView.clipsToBounds = true
    imageView.contentMode =.scaleAspectFit

Q2: Need to change x position of "Accessory" present in every cell.(Refer reference image 2)

A: on your rearView change the width of tableview (not a fullscreen width use fullscreenwidth - 30 )

if your rear view as a tableviewcontroller then change the frame in viewWillAppear or ViewDidAppear

  func viewDidAppear(_ animated: Bool) {

    super. viewDidAppear(animated)
    tableView.frame = CGRect(x: 0, y: yourYPosition, width: self.view.frame.size.width - 30, height: self.view.frame.size.height)
    UIApplication.shared.keyWindow?.backgroundColor = UIColor.white

}

Upvotes: 1

Related Questions