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 Safe Area Layout Guides

James Rimmer
James Rimmer
2,603 Points

Yet another link missing in the Teacher's Notes for setup code...

In the video, Pasan states that there is a link in the Teacher's Notes to find the setup code. Usually, Pasan helpfully posts a link to a relevant GitHub page of his containing the code which you can copy and paste, but the link is missing. I've noticed this with three of the videos in the 'Programmatic Auto Layout' workshop now - was that workshop QA'd before release? I'm happy to help out with that sort of thing if Treehouse needs help, but whoever does it I'd strongly recommend that it is done as it looks a bit amateurish to refer to missing resources - particularly now that I've seen this with three videos in the workshop.

Jason Anders
Jason Anders
Treehouse Moderator 145,860 Points

Moderator note: Duplicate posts for this topic have been deleted from the community. Please refrain from multiple posting for the same topic. Thank-you.

The Treehouse Community is a great place to get help with code from fellow students, but it is often not such an effective way to connect with the Staff who would be needed to address this problem.
It is best when you notice something like this to send a note the Treehouse Support Team, as they can then make sure the appropriate staff are notified and a remedy implemented sooner.

Remember though... Treehouse does operate within normal Monday to Friday business hours. So, sometimes on weekends, you don't get a response immediately.

Jason ~Treehouse Community Moderator :dizzy:

1 Answer

SafeAreaInsets.swift

import UIKit

class SafeAreaInsetsController: UIViewController {

let customView = UIView()

override func viewDidLoad() {
    super.viewDidLoad()
    customView.backgroundColor = .red
}

override func viewWillLayoutSubviews() {
    super.viewWillLayoutSubviews()

    customView.translatesAutoresizingMaskIntoConstraints = false
    view.addSubview(customView)

    NSLayoutConstraint.activate([
        customView.widthAnchor.constraint(equalToConstant: 200),
        customView.heightAnchor.constraint(equalToConstant: 200),
        customView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor),
        customView.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor)
        ])
}

}

you're welcome