如何调整imageView的大小? [英] How to resize the imageView?

查看:338
本文介绍了如何调整imageView的大小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何调整imageView的大小?
Xcode表示从未使用过imageView的初始化。

How do I resize the imageView? Xcode says initialisation of imageView was never used.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")
    let city = nicosiaPlaces [indexPath.row]
    cell?.textLabel?.text = city
    let imageView = CGSize(width: 100, height: 100)
    cell?.imageView?.image = UIImage(named: city)
    return cell!
}


推荐答案

您只需创建一个新的CGSize每次调用方法时,都应该改变单元格类的大小。如果您使用故事板与AutoLayout,您应该更改故事板中的大小。

You just create a new CGSize every time when the method is called, you should change the size in your cell class instead. And if you're using storyboard with AutoLayout, you should change the size in storyboard.

这篇关于如何调整imageView的大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆