Group buttons together for easy manipulation
I am trying to group related buttons together so that I can show/hide/move them all as one. I have determined that using a UIView would probably be the best bet however, when I try this the the sub view doesn't show u开发者_Python百科p. I'm wondering what I may be doing wrong.
UIView *playerView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, view.frame.size.width, 50)];
[playerView setBackgroundColor:[UIColor colorRed]];
[view addSubview:playerView];
Am I doing something obviously wrong?
Just tried it. It works for me, but you need to fix one small thing:
colorRed -> redColor;
[playerView setBackgroundColor:[UIColor redColor]];
Are you sure that view.frame.size.width is > 0 at that time? Where does that code get executed?
Try using a number for the width instead of view.frame.size.width and see if you get different results.
The only thing I can see in your code that might cause this is if the view.frame.size.width is 0. Is "view" itself visible?
精彩评论