Friday, November 6, 2026
HomeiOS Developmentios - How do I get and retailer an preliminary worth of...

ios – How do I get and retailer an preliminary worth of a property of a UIView?

[ad_1]

I’ve a UIView laid out and constrained in foremost.storyboard, and have an IBOutlet connecting it to its corresponding ViewController class in ViewController.swift.

I want to control the place of the view in numerous completely different features, and to do that I want to have the ability to entry the worth of the preliminary y-position of the view. I attempted to do that utilizing

public let inputRest = self.userInputView.body.origin.y

within the physique of the ViewController class. Nevertheless, this offers me the error Can't use occasion member 'userInputView' inside property initializer; property initializers run earlier than 'self' is obtainable.

How do I retailer properties of occasion members in variables to be able to name them in a operate? Is there a strategy to declare this variable in viewDidLoad() and entry it in different features?

Thanks for the assistance.

[ad_2]

RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Most Popular

Recent Comments