Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

iOS Build an Interactive Story App with Swift Creating the User Interface Programmatically Creating Views Programmatically

Anchoring to the bottom the of the navigation

How would you anchor the top anchor of the image to the bottom anchor of the navigation in the controller ?

1 Answer

I'm basing this answer off of one of the answers from http://stackoverflow.com/questions/17074365/status-bar-and-navigation-bar-appear-over-my-views-bounds-in-ios-7/18976660#18976660

Programmatically, you could adjust for it by adding the length of the "topLayoutGuide" as a constant to the constraint:

let topAdjust = self.topLayoutGuide.length

        artworkView.topAnchor.constraint(equalTo: view.topAnchor, constant: topAdjust),
       // other constants same

Note: all the other constraints would remain the same, you just need to add the extra "constant" parameter to the artworkView.topAnchor.constraint