KeVal
KeVal

Reputation: 351

Changing font for multiple Labels in Xcode storyboard

How could I change font and colour of text for MULTIPLE Labels (all in one UIViewController) with one code, without having to make an outlet for every Label. I'm using storyboards.

Font has to be changed in code because it is not listed with all the others

Upvotes: 0

Views: 1363

Answers (1)

mjay
mjay

Reputation: 241

You can use an IBOutletCollection instead of many IBOutlets.

@property (strong, nonatomic) IBOutletCollection(UIView) NSArray *fontViews;

And then set the fontsize or whatever you want in a loop:

for (UITextView *view in self.fontViews) {
        if ([view respondsToSelector:@selector(setFont:)]) {
            [view setFont:[UIFont systemFontOfSize:20]];
        }
    }

Upvotes: 1

Related Questions