Any way of getting this to work on kotlin native? ...
# kotlin-native
c
Any way of getting this to work on kotlin native? For example in Swift I can do:
Copy code
let label = UIView()
label.frame.origin.x = ...
I cant seem to find where I can update the
x
in kotlin..
a
Hi there! I suppose you can try something like this:
Copy code
memScoped {
    val view = UIView()
    val rect = view.frame()
    val oldFrame = rect.getPointer(this).pointed
    oldFrame.origin.x += 10
    val newFrame :CValue<CGRect> = CGRectMake(oldFrame.origin.x, oldFrame.origin.y, oldFrame.size.width ,oldFrame.size.height )
    view.setFrame(newFrame)
  }
This can be an overkill in some moments, but. I’m not sure one can do something easier with
CValue<...>
.
👍 2
c
Thanks for the answer! Yeah, what I found is that I could access the values using
useContents
but found it too cumbersome to work with. Either way, I was using constraints, so it was just a matter of putting up the constraint for the
leftAnchor
as a variable and update it accordingly.