0

Is it possible to give a tableview a custom origin/size? Adding a Backgroundimage to a Tableview is explained here enter link description here. But can i tell in viewdidload the position of it?

I thought about something like:

mytableView.backgroundView?.frame.origin = CGPoint(x: 100, y: 100)

or

mytableView.backgroundView?.frame = CGRect(x: 100, y: 100, width: 100, height: 100)

implementing in viewDidLoad(). But it just fills the whole UIScreen and doesn't react on the code.

Thanks in advance.

Community
  • 1
  • 1
S. Birklin
  • 1,255
  • 1
  • 13
  • 19
  • r u try to set the background image for table view or try to change the frame of tableview – Anbu.Karthik Sep 04 '15 at 11:24
  • but your coding is fine , if you are used in the auto layout change the constraint – Anbu.Karthik Sep 04 '15 at 11:27
  • The frame of tableview is fine. But i want to change the frame of the background image of tableview. By the way, I just try to add some constraints and it looks like it changes its position. But i thought actually that the code above should solve it. – S. Birklin Sep 04 '15 at 11:30

2 Answers2

1

You can have a one custom UIView which has clear background color UITableView inside of it. Then you can add UIImageViewback of this UITableView. You'd know the tableView's frame and resize your imageView's frame and origin whatever you like.

Sabrican Ozan
  • 738
  • 3
  • 9
0

Here is the simple solution:

  • Set background image view to UIView.
  • Add UITableView on that UIView.
  • Set UITableView background color as clear color.
  • Now you can reset any position either of UITableView or background UIImageView. It will work fine.
Idrees Ashraf
  • 1,363
  • 21
  • 38