Objective-C setFrame Swift equivalent

I have an Objective-C project that I am refactoring and I selected a line that I cannot translate and the Apple documentation site does not seem to work:

[self.stepperView setFrame:self.stepperView.frame];

I tried this:

    self.stepperView.frame = stepperView.frame

but the view is still painted in the wrong place. Does anyone know the equivalent setFramein Swift?

I tried looking at the Apple documentation , but the site does not seem to be working:

enter image description here

+4
source share
2 answers

setFrameand frameequivalent in Objective-C and Swift.

Objective-C, setFrame - setter . ( Objective-C) view.frame = someFrame, 100% setFrame:, , .

Swift setVariable: - view.frame = ....

, , . , , . , iOS y, , , .

, " viewDidLoad". viewDidLoad - . :

This method is called after the view controller has loaded its view hierarchy into memory. This method is called regardless of whether the view hierarchy was loaded from a nib file or created programmatically in the loadView method. You usually override this method to perform additional initialization on views that were loaded from nib files.

viewDidLoad - , , , , - viewDidLoad viewDidAppear - , - . .

+7

Outlet, , view.frame , translatesAutoresizingMaskIntoConstraints = true , , Auto Layout Xcode

Auto Layout, view.frame viewDidLoad(),

subviews view.frame, Auto Layout . , , clipToBounds true Clips Subviews , .

, Swift, Objective-C

0
source

Source: https://habr.com/ru/post/1616309/


All Articles