我是新的swift语言... 制作带图片的简单表格,并希望在单元格内设置图像视图的角半径。ios在表格视图单元格图像中出现故障
代码: -
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier)!
cell.textLabel?.text = "Test"
cell.detailTextLabel?.text = "\(indexPath.row)"
if(cell.imageView != nil){
cell.imageView?.image = UIImage(named: "avatar")
cell.imageView?.layer.cornerRadius = cell.imageView!.frame.size.height/2
cell.imageView?.layer.masksToBounds = true
}
return cell
}
不知道我在做什么错,但是当我开始滚动表它正确设置圆角半径不seted当表显示...
编辑: - 与cell.imageView?.layer.cornerRadius = 20
得到很好的结果不知道它为什么与静态值一起工作。
是否使用自动版式? – technerd
@technerd,是的,我正在使用它.. –
ImageView的大小是固定的还是取决于长宽比? – technerd