Re:Your First iOS App – 100% Programmatically
by SeoxyS on Tuesday April 16, 2013 @08:05PM
(#5561735)
Or you could use a loop :).
for (UILabel *l in @[self.usernameLabel, self.firstNameLabel, …]) {
l.textAlignment = UITextAlignmentRight;
l.textColor = [UIColor redColor];
}
Re:Your First iOS App – 100% Programmatically
by bennyg on Tuesday April 16, 2013 @09:54PM
(#5562169)
Or use a helper class (called Design.m/.h) with a call:
+(void)styleLabelForCertainPage:(UILabel *)label {
label.textAlignment = UITextAlignmentRight;
label.textColor = [UIColor redColor];
}
Then run those through your loops. If you're seriously considering writing a lot of lines for something trivial, then you're probably doing it wrong in Objective-C.
Re:Your First iOS App – 100% Programmatically
by BHSPitMonkey on Tuesday April 16, 2013 @05:56PM
(#5561198)
If your iOS code comes out looking that repetitive, sub-optimal code organization is probably the real culprit.
Re:Your First iOS App – 100% Programmatically
by smj2118 on Tuesday April 16, 2013 @08:12PM
(#5561761)
What about UIAppearance? You can specify appearance for a UILabel inside a specific container type.
Re:Your First iOS App – 100% Programmatically
by sjdev on Tuesday April 16, 2013 @10:22PM
(#5562268)
I love UIAppearance. I am not too well versed in CSS but UIAppearance adds a lot of what I have seen done with CSS. You can change the default appearance of most default elements really easily, and declare containers inside of that with a whole different set of defaults. It makes styling your app a really painless process. All you have to do to make all the UIToolbars in your app red, for example, is use this one line at the start of your program.
[[UIToolbar appearance] setTintColor:[UIColor redColor]];
Re:Your First iOS App – 100% Programmatically
by manmal on Tuesday April 16, 2013 @06:27PM
(#5561372)
You could write generator/setter methods for aligning labels to the right, no need for inheritance here. But, smart categories and inheritance go a long way. The last time I tried IB, I really regretted it because I constantly had to click through all those element layers (object hierarchy inspector is not that good either). After about 2h I gave up and rewrote everything to code-only.
I find IB's WYSIWYG to be a lesser evil.