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
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.
3 Comments
Ryan
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?
jrturton
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?
jrturton
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