【发布时间】:2015-02-16 07:04:02
【问题描述】:
您好,我想在 UITableview 中显示图像,而在 uitableview 之上我需要透明视图。
我试过的是:
在故事板和 UITableView 之上添加了视图。
_vaultView.backgroundColor = [UIColor colorWithRed:26/255.0f green:188/255.0f blue:156/255.0f alpha:0.85f];
Ian 无法显示透明视图。
请建议我如何进行下一步。
编辑:
- (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;
}
【问题讨论】:
-
你想做什么?只是显示视图?
-
是的,我想在 uitableview 上显示视图
-
你可以使用 _vaultView.backgroundColor = [UIColor clearColor];
-
需要具有 RGB 值的视图背景颜色,例如 _vaultView.backgroundColor = [UIColor colorWithRed:26/255.0f green:188/255.0f blue:156/255.0f alpha:0.85f];
-
for transparentView 用户 ClearColor
标签: ios objective-c iphone uitableview uiview