iOS tableView表視圖設置背景圖片
經常遇到要給tableView設置背景圖片的問題,但如果直接設置背景 backgroundView的話,背景圖不會顯示,原因是 tableView上的cell默認是不透明的顏色,所以解決方法是 讓 cell透明即可:
1.給tableView設置背景view UIImageView *backImageView=[[UIImageViewalloc]initWithFrame:self.view.bounds]; [backImageView setImage:[UIImageimageNamed:@"liaotianbeijing"]]; self.tableView.backgroundView=backImageView; 2.讓cell透明 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { MyCell *cell = [tableViewdequeueReusableCellWithIdentifier:@"METext"forIndexPath:indexPath]; cell.backgroundColor=[UIColor clearColor];//關鍵語句 [cell setCellInfo:dic];//自定義類目方法 return cell; }
本文由用戶 gcd8 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!