I have a button and I’m using CGRectMake to position it like this:
btn5.frame = CGRectMake(211, 280, 109, 60);
I guess 211 and 280 are the coordinates of the button. So how can I modify that code if I want the button to be near the bottom left corner.
Yes, you are correct. The frame of the button defines where it is located on its parent view. So
btn5will be in the position (x = 211, y = 280) and will have the dimensions (width = 109, hight = 60) if you use this code:The general expression is:
If you want to change the position of the button to the bottom left corner, you can do like this:
If you want to add some space between the button and the corner, and also change the size of the button:
For more information, check Apple’s View Geometry and Coordinate Systems guide.