UIControl has two properties that are documented to affect the layout of content in the control's view:
contentHorizontalAlignment
The horizontal alignment of content (text or image) within the receiver.
controlVerticalAlignment
The vertical alignment of content (text or image) within the receiver.
I have a UIControl subclass that manages a set of five subviews; each subview is a custom UIView subclass (i.e. not a UILabel or UIImageView).
The behavior I'd like to get is UIControl managing the layout of my custom subviews using the contentHorizontalAlignment
and contentVerticalAlignment
properties.
From my experimentation, it does not appear that UIControl actually honors either of these property values when doing subview layout, at least when the subview's are not labels or images. I'm not 100% sure that my subclass is properly implemented, though.
My questions are three-ish:
- Does UIControl implement any layout behavior around these properties?
- Is it only for subviews that are UILabel and UIImageView?
- Do I have to provide the implementation for subview layout in my UIControl subclass?
- Are these properties present in the UIControl base class mainly to provide a caller's with a consistent API for managing content?
I'm expecting UIControl to provide some kind of base-level layout behavior given the presence of contentHorizontalAlignment
and contentVerticalAlignment
properties.
Am I off-base? I don't object to implementing my own layout behavior. I just don't want to be fighting the framework if UIControl already provides some layout behavior that I should be using.
Thanks,
Bill