有时显示cell的图片会有圆角或者圆形的需求,具体代码如下,可根据自己对圆角半径的大小需求做相应数值的调整:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *addressCellDentifier = @"addressCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:addressCellDentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:addressCellDentifier];
cell.imageView.frame = CGRectMake(0.0, 0.0, 60.0, 60.0);
// 圆角cell
CALayer *cellImageLayer = cell.imageView.layer;
// [cellImageLayer setCornerRadius:cell.imageView.frame.size.width / 2];
[cellImageLayer setCornerRadius:23.0];
[cellImageLayer setMasksToBounds:YES];
cell.imageView.image = [UIImage imageNamed:@"你的图片名"];
return cell;
}