简体   繁体   中英

How to make the area above UITableView transparent

My original necessary was to make the area above uitableview transparent and show the imageview under it, just like this:

在此处输入图片说明

I know there are many ways to implement this effect and I just wonder why cells can be transparent and show the content under them but the area above uitableview can't. Is there any way?

UITableView的背景色设置为clearColor

将ui tableview背景色设为透明色

If you want transparent area only once then create UIView with background color clearColor . And set UITableView header view tableView.tableHeaderView = headerView;

If you want transparent area for every section then -

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
     //return height of transparent area
}

then,

-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
      // return UIView with clearColor.
}

如果您使用的是分组的表格视图(我看不到您提供的图像):

[self.tblView setBackgroundView:nil];

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM