2012-12-21 100 views
0

我有一個UIView與一些半透明的部分(alpha < 1.0)和其他不透明。我想把按鈕設置爲不透明的子視圖,我注意到它們的部分也變成了半透明的按鈕,而在不透明按鈕的其他部分,即使設置爲alpha = 1.0,也不能看到它們。UIView半透明按鈕不可見

-(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

嘗試設置你的UIView半trasparent這樣:

myView.backgroundColor =的UIColor colorWithRed:0.1F綠色:.1F藍:.1F阿爾法:.7f]。

設置阿爾法值