Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

ios

uilabel

swift

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.

like image 671
Usman Avatar asked Dec 05 '22 11:12

Usman


1 Answers

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.

like image 129
rmaddy Avatar answered Dec 07 '22 23:12

rmaddy