I am upgrading my Objective-C code to Swift. I want to update the frame based on the image size like below:
let imageViewFrame: CGRect = view.frame
if (image.size.width <= image.size.height) {
imageViewFrame.origin.x = (view.frame.size.width - view.frame.size.height)/4
imageViewFrame.size.width = view.frame.size.height
}
here I am getting an error saying: "Cannot assign to the result of the expression" what I should do to remove the error?
Thanks in Advance!
You're declaring imageViewFrame
using let
which makes it immutable.
You could use var
instead of let
for imageViewFrame
which would make it mutable.
var imageViewFrame: CGRect = view.frame
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With