ios - 在具有透明 View 的 UITableview 中显示图像列表

标签 ios objective-c iphone uitableview uiview

您好,我想在 UITableview 中显示图像,在 uitableview 之上我需要透明 View 。

我试过的是:

在 Storyboard 中添加了 View ,并在其之上添加了 UITableView。

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

Ian 无法显示透明 View 。

请建议我如何进一步进行。

编辑:

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

最佳答案

根据我对 viewController 中 View 堆栈的理解,您只需将透明 View 移动到堆栈的前面(它当前位于 superView 的后面)。

您可以通过调用来完成此操作。

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

并且在 storyboard只需将 View 设置为正确的值

如果你想隐藏 View 只需调用

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

编辑

在你身上创建一个透明 View UITableView , 你需要添加一个 UIViewstoryBoard那是一个subView你的viewController主视图(然后在属性检查器中设置你想要的所有属性)。你的tableView还需要是 subView你的viewController主视图。

*确保透明 View 在tableView 的前面在你的storyBoard

为了处理手势(因为透明 View “阻挡”了来自 ​​tableView 的手势,请阅读这篇文章 Link)

关于ios - 在具有透明 View 的 UITableview 中显示图像列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28536101/

相关文章:

ios - 如何在 AVQueuePlayer 中循环播放声音队列?

iphone - 使屏幕变暗,就像警报一样?

iphone - 如何判断 UITableViewCell 内的 UISwitch 何时被点击?

iphone - 尝试使用 MPMoviePlayer 时出现链接器错误

iphone - 重新登录时 Facebook iOS Api 调用失败,但 isSessionValid 为 YES

ios - @2x 图像的低分辨率

objective-c - 是否可以在 View 中的两个表之间使用 UIViewAnimationTransitionFlipFromRight,而不是两个 UIView?

c++ - 如何在 *C* 中围绕命令行程序编写 GUI 包装器?

php - 无法连接到 ssl ://gateway. sandbox.push.apple.com:2195(连接被拒绝)

iphone - 从 UIWebView 打开时,订阅的日历名称具有 .ics URL