How to make UILabel a child of another UILabel in Interface Builder?
I need to make a half of a sentence red and the other half blue, so I placed two different UILabels in Interface Builder and changed their colors accordingly using the GUI. On the Objective-C side, sometimes I need to hide and reveal the sentence.
self.redHalf.hidden = YES; self.blueHalf.hidden = YES; self.redHalf.hidden = NO; self.blueHalf.hidden = NO;
This is not modular code. I'd rather just make one call to hide or reveal the whole sentence. So I tried to make one half the child of the other half by dragging one atop the other in Interface Builder, but nothing happened.
You cannot make subviews in a UILabel in IB. (You can do it in code though.)
Just drag out a generic UIView in IB and make both UILabels subviews of the generic UIView. Then set the generic UIView's hidden property to hide or show both labels.