user3766930
user3766930

Reputation: 5829

Why I cannot apply constraints to the photo in the UITableView header?

In my storyboard I have a UITableView and above the dynamic cells I added a UIView to keep there a photo and some labels.

Currently, I want to apply constraints to the photo so that it reaches the top, left and right side of the screen and keeps the aspect ratio. However, the storyboard looks like this:

enter image description here

The constraints for photo are:

enter image description here

enter image description here

However, as you see, the constraints are marked in red and when I run the app the photo is not stretched properly.

What is causing this issue?

Upvotes: 0

Views: 57

Answers (1)

livtay
livtay

Reputation: 573

I would probably do this programmatically. It is pretty simple to create a custom view and set it as your header view. You can either create a UIView with a UIImageView inside of viewForHeader or by assigning it to the entire table with tableView.tableHeaderView = headerView.

Upvotes: 1

Related Questions