I want to reset a UIView's frame size so I wrote:
view.frame.size.width = x;
but it doesn't work, can anyone tell me why?
1) Control-drag from a frame view (e.g. questionFrame) to main View, in the pop-up select "Equal heights". 2)Then go to size inspector of the frame, click edit "Equal height to Superview" constraint, set the multiplier to 0.7 and hit return.
SwiftUI's built-in frame modifier can both be used to assign a static width or height to a given view, or to apply “constraints-like” bounds within which the view can grow or shrink depending on its contents and surroundings.
you can't set width directly, do this
CGRect frm = view.frame;
frm.size.width = x;
view.frame = frm;
When you call view.frame
you get a copy of the frame rect property so setting it is with frame.size.width
changes the width of the copy and not the view's frame size
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