UIView半透明的按钮是不可见的



我有一个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];
}

按钮仍然可以工作,这只是一个可见性的问题。我能做什么?

尝试用这种方式设置你的UIView半透明:

myView。backgroundColor = [uicololcolorwithred:0.1f green:。]蓝色:1 f。α1 f: .7f];

设置alpha值

最新更新