Kep*_*tos 1 objective-c uitableview uiimage tableviewcell ios
我有一个带有imageview和label的自定义单元格.当用户在tableview中选择一个特定单元格时,我想要更改图像颜色或色调.我设法改变了标签的颜色,但不知道如何处理图像.有任何想法吗?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"MenuCell";
MenuTableViewCell *cell = (MenuTableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[MenuTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
// cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.lblTitle.text = [[_items objectAtIndex:[indexPath row]] valueForKey:@"title"];
cell.imgIcon.image = [UIImage imageNamed:[[_items objectAtIndex:[indexPath row]] valueForKey:@"image"]];
cell.lblTitle.highlightedTextColor = [UIColor colorWithRed:0.839 green:0.682 blue:0.047 alpha:1];
cell.selectionStyle = UITableViewCellSelectionStyleGray;
return cell;
}
Run Code Online (Sandbox Code Playgroud)
谢谢
小智 6
您应该更改MenuTableViewCell自定义类中的单元格数据.那里将有一个控制所选突出显示状态的方法.该方法看起来像这个例子,
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
if (selected) {
//Change the text colour & image
} else {
//Change it back to whatever is was
}
Run Code Online (Sandbox Code Playgroud)
}
归档时间: |
|
查看次数: |
4319 次 |
最近记录: |