0

There's a UILabel in Interface Builder without a custom class or tag. I need to programmatically change the y coordinate of this UILabel. I know I can reference the UILabel by setting the tag and using viewWithTag. But how do I do it with IBOutlet? Can I set the custom class in IB and then somehow reference the custom class and assign it to an IBOutlet var?

1 Answer 1

1

You don't need the label to have a custom class for this. Add an outlet to the owning class (typically, the view controller):

@IBOutlet var label: UILabel

Then in the storyboard, drag from the outlet in the connections inspector over to the label in interface builder.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks. I don't think I have a storyboard as Main Interface is blank. Can't I do something with the empty circle that formed to the left of the IBOutlet var?
What is the name of the file you are editing, is it a .xib or a .storyboard? Can you add a screenshot of interface builder to your question?
The empty circle is what you drag from to make the connection, if you can see that then hopefully things are wired up properly, but there are a number of different configurations of what you see in interface builder and what you're editing so it's hard to answer without a bit more detail from you

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.