Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using float values in storyboard

I want to to assign a float value to a UIButtons frame in Storyboard. enter image description here

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?

like image 657
Eli Braginskiy Avatar asked Feb 13 '23 17:02

Eli Braginskiy


1 Answers

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.

like image 104
matt Avatar answered Mar 19 '23 08:03

matt