I want to to assign a float value to a UIButtons frame in Storyboard.
But I can only use int values. Is it discouraged to use .5 for example? because I have some buttons and I want to place them according to the original photoshop design.
for example I have a button I need to be placed at X:151 , how can I achieve that?
Do NOT use a float value. As you have rightly observed, Interface Builder prevents this; but you should not do it even in code. Just the opposite: when you assign a frame (or related component) in code, you should set it to an integral value first. (In fact, there are even functions such as CGRectIntegral
to help you.)
The reason is that otherwise you can end up between pixels on the screen, and the view will not display correctly (because there is no such thing as half a pixel). Stick to whole numbers of points so that you are using whole numbers of pixels.
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