Cannot assign to property: 'width' is a get-only property [duplicate]
Asked Answered
R

1

8

I am new to Swift. I am getting this error:

Cannot assign to property: 'width' is a get-only property

While using this statement:

 cell.reciverMsg.frame.width = cell.reciverMsg.text?.characters.count * 2

reciverMsg is an UILabel.

Radloff answered 12/7, 2018 at 6:27 Comment(0)
H
23

You need to set the width of the frame's size property.

cell.reciverMsg.frame.size.width = 20

The width property of frame is just a read-only convenience. See the documentation for CGRect for details.

Hypnotherapy answered 12/7, 2018 at 6:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.