Skip to content

Instantly share code, notes, and snippets.

@rcdilorenzo
Created September 4, 2013 13:44
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rcdilorenzo/6437136 to your computer and use it in GitHub Desktop.
Save rcdilorenzo/6437136 to your computer and use it in GitHub Desktop.
#define IMAGE_WIDTH 100.0
#define IMAGE_HEIGHT 100.0
@implementation SOMaskScrollView
- (id)initWithFrame:(CGRect)frame {
self = [super initWithFrame:frame];
if (self) {
self.backgroundColor = [UIColor whiteColor];
// Initialization code
}
return self;
}
- (void)layoutSubviews {
UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:self.frame];
CGFloat totalImages = 20;
UIImage *repeatImage = [UIImage imageNamed:@"stripe_black.png"];
scrollView.contentSize = CGSizeMake(self.frame.size.width, totalImages*IMAGE_HEIGHT);
for (int count = 0; count < totalImages; count++) {
UIImageView *imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, count*IMAGE_HEIGHT, IMAGE_WIDTH, IMAGE_HEIGHT)];
imageView.image = repeatImage;
[scrollView addSubview:imageView];
}
[self addSubview:scrollView];
CAShapeLayer *maskLayer = [CAShapeLayer layer];
maskLayer.path = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(self.frame, 5, 5) cornerRadius:50.0f].CGPath;
self.layer.mask = maskLayer;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment