我想爲UITableView單元格imageView設置邊距或填充,我該怎麼做? With heightForRowAtIndexPath
我只能設置行高。如果我增加它,它只是放大單元格中的圖像。UITableViewCell imageView填充
這裏是我的cellForRow方法
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *cellID = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellID];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellID] autorelease];
cell.textLabel.numberOfLines = 1;
cell.textLabel.font = [UIFont systemFontOfSize:kSystemFontSize];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.textLabel.textColor = [UIColor whiteColor];
}
cell.textLabel.text = [_dataArray objectAtIndex:indexPath.row];
cell.imageView.image = [UIImage imageNamed:[_imageArray objectAtIndex:indexPath.row]];
cell.backgroundColor = [UIColor clearColor];
return cell;
}
目前我只知道一個方法,我怎麼能做到這一點 - 收縮使用Photoshop或similiar程序在同一時間停留,而圖像的圖像內容。但是這種方法會花費很多時間,我想應該有更簡單的方法來做到這一點。
這是一個聰明的主意!順便說一下,右側表達式可以進一步簡化爲'CGAffineTransformMakeScale(0.5,0.5)'。 – Pang 2015-12-14 05:45:08
不適用於我。 – 2016-10-04 07:34:23