Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone SDK: Non-transparent subviews in transparent view
    primarykey
    data
    text
    <p>I have a subview that has been added to my UIView. The idea is that the subview is a hovering panel with uibuttons. The subview is given an alpha of 0.2, as the user needs to be able to see what is behind it. </p> <p>The problem is that when I add uibuttons to the subview, they inherit the alpha from the subview (I want the buttons to be non-transparent and have an alpha of 1.0). I've tried to tackle this problem by iterating through the uibuttons and setting their alpha back to 1.0 without success. Solutions?</p> <pre><code> // Create the subview and add it to the view topHoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; topHoverView.backgroundColor = [UIColor blackColor]; [topHoverView setAlpha:0.2]; [self.view addSubview:topHoverView]; // Add button 1 button1 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button1 setFrame:CGRectMake(20, 10, 80, 30)]; [button1 setTitle:@"New" forState:UIControlStateNormal]; [button1 addTarget:self action:@selector(button1Action:) forControlEvents:UIControlEventTouchUpInside]; [topHoverView addSubview:button1]; // Add button 2 button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button2 setFrame:CGRectMake(120, 10, 80, 30)]; [button2 setTitle:@"Clear" forState:UIControlStateNormal]; [button2 addTarget:self action:@selector(button2Action:) forControlEvents:UIControlEventTouchUpInside]; [topHoverView addSubview:button2]; // Add button 3 button3 = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button3 setFrame:CGRectMake(220, 10, 80, 30)]; [button3 setTitle:@"Delete" forState:UIControlStateNormal]; [button3 addTarget:self action:@selector(button3Action:) forControlEvents:UIControlEventTouchUpInside]; [topHoverView addSubview:d button3]; // Attempt to iterate through the subviews (buttons) to set their transparency back to 1.0 for (UIView *subView in topHoverView.subviews) { subView.alpha = 1.0; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload