2016-04-17 5 views
1

私は私のビューコントローラコンテナビューの背景を透明にするにはどうすればいいですか?

、この容器ホールドXIBの上にコンテナビューを持っており、このXIBで写真を持って

問題は写真がPNG形式れると私は、コンテナは私に私の表示色を表示するように透明になりたいです

enter image description here

enter image description here

public func collectionView(collectionView: UICollectionView, cellForItemAtIndexPath indexPath: NSIndexPath) -> UICollectionViewCell { 

    let cell = collectionView.dequeueReusableCellWithReuseIdentifier("TNImageCell", forIndexPath: indexPath) as! TNImageSliderCollectionViewCell 
    cell.backgroundColor = UIColor.clearColor() 
    cell.imageView.image = images[indexPath.row] 
    cell.labelSliderName.text = sliderNames[indexPath.row] 
    return cell 

} 

私はコンテナ

答えて

3

を埋める方法このサンプルでは、​​これを試してみてください:tableView.backgroundColor = UIColor.clearColor()

let cell = collectionView.dequeueReusableCellWithReuseIdentifier("TNImageCell", forIndexPath: indexPath) as! TNImageSliderCollectionViewCell 
cell.backgroundColor = UIColor.clearColor() 
cell.imageView.image = images[indexPath.row] 
cell.imageView.alpha = 0.5 
cell.labelSliderName.text = sliderNames[indexPath.row] 
return cell 
+0

これは写真のアルファ0.5を作成しますが、写真のアルファ= 1だけを表示したいコンテナの背景を透明にしたい – MOMMH

+0

それは上のレイヤー上にimageViewが表示されるためです。 – Khuong

+0

http://i.stack.imgur.com/OR29E.pngこの図形は透明です。私は青い背景にしたいです。 – MOMMH

2

あなたはないalpha.Alpha値が同様にすべてのサブビューに適用されるコンテナの背景色の不透明度の値を変更する必要があります。

関連する問題