Iphone 透明滚动视图上的非透明按钮有问题

Iphone 透明滚动视图上的非透明按钮有问题,iphone,objective-c,cocoa-touch,xcode,Iphone,Objective C,Cocoa Touch,Xcode,我已经创建了一个scrollview,并且在这个scrollview上放置了一些按钮。scrollview是透明的,alpha=0.5。事实上,我的按钮也是透明的,尽管它们被设置为alpha为1,并且它们的不透明度被设置为YES。我知道我在任何superView视图中添加了任何子视图,那么superView的属性应该适用于它的子视图。但是我希望所有的按钮都被放置在透明的滚动视图上是不透明的。 请给我一些建议。您可以演示一下subview如何不继承SupperView的属性吗? 谢谢你的回复 [i

我已经创建了一个scrollview,并且在这个scrollview上放置了一些按钮。scrollview是透明的,alpha=0.5。事实上,我的按钮也是透明的,尽管它们被设置为alpha为1,并且它们的不透明度被设置为YES。我知道我在任何superView视图中添加了任何子视图,那么superView的属性应该适用于它的子视图。但是我希望所有的按钮都被放置在透明的滚动视图上是不透明的。 请给我一些建议。您可以演示一下subview如何不继承SupperView的属性吗? 谢谢你的回复

[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];
  }
}
[i]-(无效)viewDidLoad{
[超级视图下载];
DefaultLayoutData=[[Database GetDefaultLayout]retain];
scrollView.contentSize=CGSizeMake(屏幕大小和宽度,480*4);
scrollView.PaginEnabled=是;
scrollView.scrollEnabled=是;
//滚动视图。
scrollView.showsHorizontalScrollIndicator=是;
scrollView.showsVerticalScrollIndicator=是;
scrollView.scrollsToTop=是;
scrollView.delegate=self;
[scrollView setAlpha:0.5];

对于(int i=0;i您真的需要您的滚动视图是半透明的吗?可能只是为它设置合适的背景色即可?类似于:

 [scrollView setBackgroundColor:[UIColor colorWithWhite:1.0f alpha:0.5f]];

scrollview后面有一个视图,它包含背景图像,我的客户希望按钮放置在透明的srollview上,他们希望下面视图的背景可见。---UIView(它包含背景图像)----UIScrollview-------(透明,alpha==0.5)-----------------------ui按钮(alpha===1,视图的背景可见。)感谢您的回复。然后为scrollview设置透明背景色必须满足您的要求