-
-
Save sebk/8648796 to your computer and use it in GitHub Desktop.
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
#import "UIScrollView+Images.h" | |
@implementation UIScrollView (Images) | |
- (void)addImages:(NSArray *)images | |
{ | |
NSMutableDictionary *viewsDictionary = [NSMutableDictionary dictionary]; | |
NSMutableString *visualFormatString = [NSMutableString stringWithString:@"|"]; | |
NSUInteger index = 0; | |
for (UIImage *anImage in images) { | |
UIImageView *imageView = [[UIImageView alloc] initWithImage:anImage]; | |
[self addSubview:imageView]; | |
imageView.translatesAutoresizingMaskIntoConstraints = NO; | |
NSString *key = [NSString stringWithFormat:@"imageView%d", index]; | |
[visualFormatString appendFormat:@"[%@]", key]; | |
[viewsDictionary setObject:imageView forKey:key]; | |
index++; | |
} | |
[visualFormatString appendString:@"|"]; | |
[self addConstraints:[NSLayoutConstraint constraintsWithVisualFormat:visualFormatString options:0 metrics:nil views:viewsDictionary]]; | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment