When I use the StoryBoard, I can add an UIImageView to UITableView like this:
I am trying to write an UIScrollView extension to add a parallax image into a UITableView which can be reused for all the tables easily. Here my code to add image:
extension UIScrollView {
func addParallaxImage(image image: UIImage, height: CGFloat) {
let myImageView: UIImageView = UIImageView()
myImageView.image = image
myImageView.contentMode = UIViewContentMode.ScaleAspectFill
myImageView.frame.size.width = UIScreen.mainScreen().bounds.size.width
myImageView.frame.size.height = height
myImageView.frame.origin.y = 0
self.addSubview(myImageView)
}
}
Function usage:
tableView.addParallaxImage(image: UIImage(named: "pets")!, height: 100)
However, my image overlaps the table.
Any solutions?
The best solution for your case is used tableview header and here the most usable libs:-
Take care not all libs support Swift, I hope I help you.