Created
April 8, 2014 11:37
-
-
Save folex/10112592 to your computer and use it in GitHub Desktop.
UIView category to add multiple subviews at once
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//.h | |
@interface UIView (AddSubviews) | |
- (void) addSubviews:(UIView*) subview1, ... | |
NS_REQUIRES_NIL_TERMINATION; | |
@end | |
//.m | |
@implementation UIView (AddSubviews) | |
- (void)addSubviews:(UIView *)subview1, ... { | |
va_list subviews; | |
va_start(subviews, subview1); | |
for (UIView *subview = subview1; subview != nil; subview = va_arg(subviews, UIView*)) { | |
[self addSubview:subview]; | |
} | |
va_end(subviews); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment