0
我已經完成了此操作,但由於某種原因它不起作用。我試圖在我的桌面視圖中有圓形圖片,除了一件事以外,一切正常:將所有圖像的大小調整爲相等大小
圖片不是全部大小相同,因此舍入不能正常工作,有些照片只是荒謬的。我正在使用下面的代碼。
UITableViewCell *cell = [self.tableView dequeueReusableCellWithIdentifier:identifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:identifier];
}
cell.imageView.layer.masksToBounds = YES;
cell.imageView.clipsToBounds = YES;;
cell.imageView.layer.cornerRadius = cell.imageView.layer.frame.size.width/2;
//Getting the picture data of the current contact
NSData *pictureData = [[[[dataArray objectAtIndex:indexPath.section]objectAtIndex:indexPath.row]picture]data];
UIImage *picture;
//Setting the picture or a placeholder if none was found
if (pictureData == nil || pictureData.length < 15){
picture = [UIImage imageNamed:@"placeholder.png"];
}else{
picture = [UIImage imageWithData:pictureData];
}
cell.textLabel.text = [[[dataArray objectAtIndex:indexPath.section]objectAtIndex:indexPath.row]compositeName];
cell.imageView.image = picture;
return cell;
我該怎麼做才能在任何時候都有圓形圖像考慮一些imageviews(顯然是...)是不同的大小。
注意,實現代碼如下細胞和圖像都是平等的高度/寬度的,他們只是得到一個cornerradius值不是他們的高度的一半明顯,但他們仍然不寬或更高。