【发布时间】:2014-03-16 06:57:51
【问题描述】:
我需要制作头像图片圈(类似于whats app) 我使用的单元格是 UITableViewCellStyleDefault
这是我的代码:
User *user = [DBHelper fetchUserWithUserID:userID];
cell.imageView.image = [Helper imageWithBlob:user.profile.thumbnailPhotoBlob defaultImageFile:FILE_DEFAULT_PHOTO];
cell.imageView.layer.cornerRadius = cell.imageView.frame.size.height /2;
cell.imageView.clipsToBounds = YES;
cell.imageView.layer.masksToBounds = YES;
但结果图像视图仍然是正方形
编辑:图像视图的框架是 {0, 0, 0, 0},但它确实显示了图像。
编辑2:
我尝试了答案,但图像不是圆形。这是我所做的:
float height = [self tableView:tableView heightForRowAtIndexPath:indexPath];
[Helper circlizeImageView:cell.imageView cellHeihgt:height];
+ (void)circlizeImageView:(UIImageView *)imageView cellHeihgt:(float)cellHeight {
imageView.frame = CGRectMake(0, 0, cellHeight, cellHeight);
[Helper circlizeView:imageView];
}
+ (void)circlizeView:(UIView *)view {
view.layer.cornerRadius = view.frame.size.height / 2;
view.clipsToBounds = YES;
view.layer.masksToBounds = YES;
}
【问题讨论】:
-
我导入了整个
。 -
我试过 QuartzCore/CoreAnimation.h 也不工作
-
您是否尝试将图像视图作为子视图添加到单元格内容视图中?
-
不,但是默认单元格已经带有图像视图
-
我编辑了问题
标签: ios uitableview uiimageview uikit