self.image.frame.width = 20 give get only property error

前端 未结 3 1021
灰色年华
灰色年华 2021-01-05 09:37

i tried to change the width of my Image view to 20 @IBOutlet weak var image: UIImageView! using this code in viewDidLoad self.image.frame.width = 20

3条回答
  •  孤独总比滥情好
    2021-01-05 10:16

    get-only means you can only read this property (for example to compare with something), but not change. To set width you need this:

    self.image.frame.size.width = foo
    

提交回复
热议问题