2

i tried to set an image as background in an UITableview.

Currect XCode Version with Simulator IOS 10.1 and 9.3

    let backgroundImageView = UIImageView(image: UIImage(named: "image.png")
    backgroundImageView.contentMode = .scaleAspectFill
    self.tableView.backgroundView = backgroundImageView

in IOS10 it looks like: enter image description here

and in IOS 9.x it looks like: IOS9

can you help me please?

Skyborg
  • 854
  • 13
  • 13
  • check my answer may help you http://stackoverflow.com/questions/40678482/how-do-i-make-this-uitableview-clear-transparent-in-swift-3/40680251#40680251 http://stackoverflow.com/questions/39976432/background-image-not-loading-on-device/39977258#39977258 – Joe Nov 21 '16 at 06:42
  • the problem is, that the tableview is behind the background image. – Skyborg Nov 21 '16 at 13:52
  • you still setting BGimage in tableview.backgroundView or in UIView as uiimage? – Joe Nov 21 '16 at 14:09
  • i set it in the tableview, and it works like a charm in IOS10 but not in 9. – Skyborg Nov 21 '16 at 15:15

1 Answers1

0

i fixed it in viewdid load with the following code only for IOS < 10:

    let SYS_VERSION_FLOAT = (UIDevice.currentDevice().systemVersion as NSString).floatValue
    if Version.SYS_VERSION_FLOAT < 10.0 {
        let backgroundImageView = UIImageView(frame: self.view.frame)
        backgroundImageView.image = UIImage(named: "image.png")
        self.tableView.addSubview(backgroundImageView)
        self.tableView.sendSubview(toBack: backgroundImageView)
    }

for IOS10 i used the original code in viewdidapear:

if Version.SYS_VERSION_FLOAT < 10.0 {
let backgroundImageView = UIImageView(image: UIImage(named: "image.png")
backgroundImageView.contentMode = .scaleAspectFill
self.tableView.backgroundView = backgroundImageView
}

The solution it not perfect but for now it works. The image is fixed in the background in the IOS10 Version, but not in the IOS9 Version.

Skyborg
  • 854
  • 13
  • 13