using Standard Values Instead of constant in Autolayout IOS -


i have started learning ios development knowledge little.

i building layout app. need app run on devices . have read somewhere should never use constant magic number when creating constraints , use standard values. want support app resolutions

whenever set standard value it's '0' means have play multiplier values have similar spacing

and kindly let me know when can use constant value , when have avoid.

most of times need space views evenly in screen . makes view similar on devices (like on bigger screen should equivalent scaled version of how looks on smaller screen).

for eg. if need space 3 views horizontally , equally on view. if set height/width of buttons magic number, 100 pixels. 3 subviews relatively smaller on iphone6+ screen on iphone5 screen. when use multipliers. height/width of buttons = 0.2 of superview.

on other hand need use magic numbers in cases.

for eg. creating canvas on screen in user draw menu panel on left. know menu panel fits in 50 pixel strip on left. if set size of menu panel multiplier, menu panel become larger on bigger screens. nullify advantage of having bigger screen draw. when use magic numbers know menu panel needed no larger 50 pixels.

(note: never use magic numbers directly. create constants k_menu_bar_height = 50. use constant wherever need. more readable , helps in long run maintenance point of view)


Comments

Popular posts from this blog

java - Static nested class instance -

c# - Bluetooth LE CanUpdate Characteristic property -

JavaScript - Replace variable from string in all occurrences -