0

我有一个 UIView,其中一些部分是半透明的(alpha <1.0)和其他不透明的。我想将按钮不透明作为子视图,我注意到它们也变成半透明按钮的部分,而在不透明按钮的其他部分,即使设置为 alpha = 1.0,您也看不到。

-(void)viewDidLoad{
  //......
  self.viewSito = [[UIView alloc]init];
  //this view has some parts semi-trasparent and other opaque

  self.buttonClose =[UIButton buttonWithType:UIButtonTypeRoundedRect];
  self.buttonClose.backgroundColor=[UIColor blackColor];
  self.buttonClose.alpha =1.0;
 /*the output is semi-transparent when is on uiview semi-transparent, but when uiview is 
  opaque the button is not visible, as if it were "hidden" from the opaque part 
  of the view.*/
  //...

 [self.viewSito addSubview:self.buttonClose];

}

按钮仍然有效,只是可见性问题。我该怎么办?

4

1 回答 1

0

尝试以这种方式设置您的 UIView 半透明:

myView.backgroundColor = [UIColor colorWithRed:0.1f green:.1f blue:.1f alpha:.7f];

设置 alpha 值

于 2012-12-23T05:29:22.487 回答