Neph
Neph

Reputation: 2001

Resize View in Xcode 10.2

To learn Swift, I'm following the steps described in Apple's "Intro to App Development with Swift" ebook. The book was released in 2017 and is using an older version of Xcode, while I'm using the latest (10.2).

Lesson 17 (page 114) tells you to create a new View and the screenshot shows a resizable element:

resizable element in the ebook

In my version of Xcode, the View automatically fills the View Controller and the dots at the corner (which suggest that you can resize it) are missing. Other questions recommend changing settings for the View Controller:

But this didn't change anything - it still won't let me resize the View. If I drag one of the corners, it either "draws" some type of selection rectangle or the View stays selected and blue (if it was already selected in the first place).

It is possible to resize an e.g. Image View though.

Is it still possible to resize a View (by dragging the corners) and if so, how do you do it?

Upvotes: 0

Views: 779

Answers (1)

glyvox
glyvox

Reputation: 58139

Every view controller has a parent subview by default. That's expected behavior and 99.9999% of the time, you'd want that anyways.

If you want to add a view to a view controller, you should add it as a subview of its parent view.

The view hierarchy should look like this:

view as a subview of the root view

That new subview should be resizable as described in the guide you mentioned:

resizable subview

Upvotes: 1

Related Questions