I've a UIView, I want to change the size when user touches a button.
CGRect newFrame = self.myview.frame; newFrame.size.width = 200; newFrame.size.height = 200; [self setFrame:newFrame]; CGRect newFrame = self.searchField.frame; newFrame.size.width = 200; newFrame.size.height = 200; self.searchField.frame=newFrame;
None of them works, don't change anything. I want to set fixed width and height to UIView.
size. width = 200; newFrame. size. height = 200; [self setFrame:newFrame]; CGRect newFrame = self.
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.
Using the frame allows you to reposition and/or resize a view within its superview . Usually can be used from a superview , for example, when you create a specific subview.
If I understand correctly, you want to change the size of self.myview
. However at no point you are setting the frame of it. Instead you are trying to call sendFrame:
on the view controller and some search field. I'm surprised, that the former one didn't give you a compiler error.
Objective C
CGRect newFrame = self.myview.frame; newFrame.size.width = 200; newFrame.size.height = 200; [self.myview setFrame:newFrame];
Swift
var newFrame = myview.frame newFrame.size.width = 200 newFrame.size.height = 200 myview.frame = newFrame
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