嘿我正在尝试设置cell.imageView
's cornerRadius
,但似乎不起作用。
cell.imageView.layer.cornerRadius=9;
它会起作用还是我应该添加自定义UIImageView
在我的牢房里有圆角吗?
我也尝试过这个
cell.imageView.layer.borderWidth=2;
cell.imageView.layer.borderColor=[[UIColor blackColor]CGColor];
但它似乎也不起作用。有人遇到过类似的问题吗?
First 添加框架 https://stackoverflow.com/a/6335001/2106973-> QuartzCore.framework 添加到您的项目中
然后导入头文件ViewController.m
file
#import <QuartzCore/CALayer.h>
在您的中添加以下代码cellForRowAtIndexPath
method:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
NSString *cellIdentifier = @"TableViewCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
// Rounded Rect for cell image
CALayer *cellImageLayer = cell.imageView.layer;
[cellImageLayer setCornerRadius:9];
[cellImageLayer setMasksToBounds:YES];
}
cell.imageView.image = [UIImage imageNamed:@"image_name.png"];
return cell;
}
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)