0

Hi I want to display images in UITableview and on top of uitableview I need transparent view.

What I have tried is :

Added view in storyboard and on top of it UITableView.

_vaultView.backgroundColor = [UIColor colorWithRed:26/255.0f green:188/255.0f blue:156/255.0f alpha:0.85f];

Ian unable to display transparent View.

Please suggest me how to proceed further.

edit:

    - (void)viewDidLoad {
        [super viewDidLoad]; 
        _vaultView.backgroundColor = [UIColor colorWithRed:26/255.0f       green:188/255.0f blue:156/255.0f alpha:0.85f];

        UILabel *lblMySaved = [self createLabelWithTitle:@"Find all your saved   work here" frame:CGRectMake(20,115,300,60) tag:1 font:[Util Font:FontTypeLight Size:18.0] color:[UIColor whiteColor] numberOfLines:0];
    [_vaultView addSubview:lblMySaved];

     _tblVault.separatorColor = [UIColor clearColor];
     _tblVault.delegate = self;
     _tblVault.dataSource = self;
     _tblVault.scrollEnabled = NO;
        [self refreshImages];
    }

     -(void)refreshImages
    {
        [aryVaultImages removeAllObjects];


       NSArray *aryImages = [self getImagesfromDB]; // Retrieving image paths   from DB
     [_tblVault reloadData];

}
        - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
     {
      return 1;
    }

     - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:     (NSInteger)section
    {

    return 2;
   }
    - (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath;
{
    return 40;

}

      - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
     {
    static NSString *cellIdentifier = @"Cell";
       UITableViewCell *cell = [tableView   dequeueReusableCellWithIdentifier:cellIdentifier];
     tableView.separatorColor =[UIColor clearColor];

    if(cell == nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];

    }
   if(indexPath.row ==0 && [aryImgPaths count])
   {
       NSLog(@"imagepath:%@",[aryImgPaths objectAtIndex:indexPath.row]);
       UIImageView *imageView = [[UIImageView alloc]initWithFrame:CGRectMake(5,5, 40, 40)];
       [imageView setImage:[UIImage imageNamed:@"deletePost11.png"]];
       [cell.contentView sendSubviewToBack:imageView];
       [cell.contentView addSubview:imageView];

   }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;

    return  cell;
}
user2931321
  • 468
  • 1
  • 7
  • 28

2 Answers2

2

From my understanding of your Views stack in your viewController, you simply need to move the transparent view to the front of the stack (it is currently at the back of your superView).

You can do this by calling.

[self.view bringSubViewToFront:<your transparent view>];

And in the storyboard just set the view to the correct values

If you want to hide the view just call

[self.view bringSubViewToFront:<your tableView>];

EDIT

To create a transparent view on top of you UITableView, you need to add a UIView in the storyBoard that is a subView of your viewController main view(then set all the attributes you want in the attributes inspector). Your tableView need to be also a subView of your viewController main view.

*make sure that the transparent view is front of the tableView in your storyBoard

In order to handle the gestures (because the transparent view is "blocking" the gestures from the tableView read this post Link)

Community
  • 1
  • 1
YYfim
  • 1,402
  • 1
  • 9
  • 24
0
tableView.backgroundColor = [UIColor clearColor];
tableView.backgroundView.backgroundColor = [UIColor clearColor];

- (void)tableView:(UITableView *)tableView willDisplayHeaderView:(UIView *)view forSection:(NSInteger)section{
if ([view isKindOfClass:[UITableViewHeaderFooterView class]]) 
{
   UITableViewHeaderFooterView *headerView = (UITableViewHeaderFooterView *)view;
    headerView.contentView.backgroundColor = [UIColor clearColor];
    headerView.backgroundView.backgroundColor = [UIColor clearColor];
}
}
ChintaN -Maddy- Ramani
  • 5,156
  • 1
  • 27
  • 48
Chandan kumar
  • 1,074
  • 12
  • 31