ios - 无法分配给属性:“宽度”是仅获取属性
问题描述
我是斯威夫特的新手。我收到此错误:
无法分配给属性:“宽度”是仅获取属性
使用此语句时:
cell.reciverMsg.frame.width = cell.reciverMsg.text?.characters.count * 2
reciverMsg
是一个UILabel
。
解决方案
您需要设置width
框架的size
属性。
cell.reciverMsg.frame.size.width = 20
的width
属性frame
只是一个只读的方便。有关详细信息,请参阅文档CGRect
。
推荐阅读
- javascript - setInterval() 方法完成整个操作后如何使警报出现
- c# - 如何将类注册为接口但调用方法?
- python - 如何连接数据库并在机器人消息中打印其内容?
- java - 在 Number 的左侧添加零
- sql - 我们如何避免使用 SQL Server 在第一页列出同一类别下的产品
- python-3.x - 如何根据绘图中的条件为折线图着色?
- python-2.7 - 为什么 isdigit 有效,但 isdecimal 不适用于简单的年龄代码
- python - 在 SqlAlchemy 上使用 distinct on (Postgres) 的正确方法是什么?
- java - 如何通过后台的连接状态更改firebase数据库?
- asp.net - 将 DLL 引用添加到独立的 ASPX 页面?