iOS App Development Book/Video Series

General Category => FAQs => Topic started by: kjmcneish on September 21, 2015, 10:53:58 AM

Title: How to add a background image to a table view
Post by: kjmcneish on September 21, 2015, 10:53:58 AM
To add a background image to a table view, you create an image view and add it to the table view's backGroundView property.

For example:

Code: [Select]
let imageView = UIImageView(image: UIImage(named: "StarrySky"))
imageView.frame = self.tableView.frame
self.tableView.backgroundView = imageView

All the best!
Kevin McNeish
Author of Learn to Code in Swift: https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11 (https://itunes.apple.com/us/book/learn-to-code-in-swift/id942956811?mt=11)
Check out our Robot Tic-Tac-Toe app: https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8 (https://itunes.apple.com/us/app/robot-tic-tac-toe/id990638517?mt=8)
Title: Re: How to add a background image to a table view
Post by: DennyS on October 08, 2015, 05:31:53 PM
How about an image above, or at the top of, a tableview that does not scroll up with the tableview.
An image view can be placed above a tableview but it scrolls up and out of sight.

The Apple documentation says how to use a header for sections of a tableview, and it says that a header can be used at the top of a tableview.
How do you put an image in the main header at the top that will not scroll up?

I want the image to stay at the top of the screen when the table is scrolled up.

I have found a way to do it using Objective-C but I want to use Swift.

Thanks
DennyS