Search code examples
iosuiviewsubviews

is it ok to access subviews of uiviews


I have seen many bright ideas to massage views and controls into looking exactly the way we want them, some of them listed here on SO:

  1. Transparent UISearchBar: iPad/iPhone uiSearchbar transparent background
  2. Different colored UISegmentedControl: UISegmentedControl selected segment color

I was wondering, is this legal? There seems to be some element of hackery involved whenever someone hardcodes something like [[view subviews] objectAtIndex:0], but it seems to be done everywhere...can someone comment on this and perhaps give some perspectives? Is it ok by the rule books? Has anyone released production code like this and has it been accepted by apple?


Solution

  • It's exposed as part of the API, therefore it's legal. Ive done it on an application currently in the App Store, and I know others have done the same.