【发布时间】:2015-09-14 19:12:34
【问题描述】:
如何在 tableViewCell 中设置 imageView 的固定大小,以便文本和图像正确对齐..
我已经尝试过以下事情
self.imageView?.frame.size.width = 40.0
self.imageView?.frame = CGRectMake(0,0,40,40)
cell.imageView.autoresizingMask = ( UIViewAutoresizingNone );
self.imageView?.autoresizesSubviews = false
cell.imageView.contentMode = UIViewContentModeCenter;
self.imageView?.bounds = CGRectMake(0, 0, 50, 50);
cell.imageView.frame = CGRectMake(0, 0, 50, 50);
cell.imageView.image = [UIImage imageWithData: imageData];
self.contentView.frame = self.bounds;
谢谢。
【问题讨论】:
-
您可以在情节提要的单元格原型中为 imageView 添加宽度和高度约束。
-
故事板中没有图像视图,你能告诉我如何从 uitableviewcell 类中做到吗?