I want to use pre-defined macros
in StoryBoard
elements
For example:
I have a 10 textfield
in my app and if I want to change the size of all textfield
through preprocessor macros
then it will be easier and faster. In that case we only need to change that macro variable.
So the core issue is the usage of shared constants for Interface Builder files.
Preprocessor macros can only be used in files that are run through the C preprocessor — essentially just your code. So you can't use macros to implement shared constants for IB files. Similarly you cannot use actual constants that you define in your code files.
What you can do, however, is to create a custom UITextField
(or any UIView
for that matter) subclass, set your constant values (or define any other custom behavior) in the subclass implementation, and then select this custom class name in Interface Builder's Identity Inspector -> Custom Class section for all of your text field elements.
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