views:

22

answers:

1

Hi all. I have created a scrollview, and some button are placed on this scrollview. And scrollview is transparent with alpha = 0.5. The fact that my buttons are also transparent despite they are set to alpha of 1 and their opacity is set to YES. And I khow that I added any subview to any superView view then the properties of superview should be applicable to its subview. But I want that all button have been placed on the transparence scrollview is not transparent. Please give me some advices. Could you please to show How subview don’t inherit the properties of SupperView? Thank you for your reply.

[i]- (void)viewDidLoad {
  [super viewDidLoad];
  DefaultLayoutData = [[Database GetDefaultLayout] retain];
  scrollView.contentSize = CGSizeMake(SCREEN_SIZE_WIDTH,480*4);
  scrollView.pagingEnabled = YES;
  scrollView.scrollEnabled = YES;
  //scrollView.
  scrollView.showsHorizontalScrollIndicator = YES;
  scrollView.showsVerticalScrollIndicator = YES;
  scrollView.scrollsToTop = YES;
  scrollView.delegate = self; 
  [scrollView setAlpha:0.5];
  for (int i=0; i<[DefaultLayoutData count]; i++) {
       NSMutableArray *BtnEntryData = [DefaultLayoutData objectAtIndex:i];
       MyUIButton* buttonCustom = [MyUIButton buttonWithType:UIButtonTypeCustom];

       buttonCustom.frame = CGRectMake([[BtnEntryData objectAtIndex:2] intValue],      [[BtnEntryData objectAtIndex:3] intValue], [[BtnEntryData objectAtIndex:5] intValue],      [[BtnEntryData objectAtIndex:4] intValue]);
       [buttonCustom setImage:[UIImage imageNamed:[BtnEntryData objectAtIndex:1] ] forState:UIControlStateNormal];
      [buttonCustom setImage:[UIImage imageNamed:[[BtnEntryData objectAtIndex:1]    stringByAppendingString:@"1"]] forState:UIControlStateHighlighted];
      [buttonCustom setAlpha:1.0];
       buttonCustom.alpha = 1.0;
      [buttonCustom setOpaque:YES];
      [buttonCustom setBackgroundColor:[UIColor redColor]];
      [buttonCustom setClearsContextBeforeDrawing:TRUE];

      [scrollView addSubview:buttonCustom];
    [scrollView setBackgroundColor:[UIColor redColor]];
    buttonCustom.scrollView = scrollView;
    ButtonArray = [buttonCustom retain];
  }
}
A: 

Do you really need your scroll view to be semitransparent? May be just setting appropriate background color for it would do? something like:

 [scrollView setBackgroundColor:[UIColor colorWithWhite:1.0f alpha:0.5f]];
Vladimir
there is a view behind scrollview and it contains background image, my clients want the button are placed on a transparent srollview and they want the background of the view below is visible.----UIView (it contains background image) -----------UIScrollview----------(transparent with alpha ==0.5)-------------------UIButton (alpha===1, the background of the view is visible.)thank you for your reply.
becktoan
then setting transparent background color for scrollview must do what you want
Vladimir