开发者

Problem with non-transparented buttons on a transparent scrollview

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* bu开发者_如何学运维ttonCustom = [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];
  }
}


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]];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜