我有一个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];
}
按钮仍然有效,这只是一个可见性问题。我该怎么办?
答案 0 :(得分:0)
尝试以这种方式将View设置为半透明:
myView.backgroundColor = [UIColor colorWithRed:0.1f green:.1f blue:.1f alpha:.7f];
设置alpha值