Skip to content

Instantly share code, notes, and snippets.

@saniul
Created June 20, 2014 21:53
Show Gist options
  • Save saniul/00daf8cc04e5bda20059 to your computer and use it in GitHub Desktop.
Save saniul/00daf8cc04e5bda20059 to your computer and use it in GitHub Desktop.
UIBezierPath Bug
+ (UIImage *)imageForCollageProxyWithType:(NSString *)collageType
highlightedIndex:(NSUInteger)highlightedIndex
fillColor:(UIColor *)fillColor
highlightedFillColor:(UIColor *)highlightedFillColor
size:(CGSize)size {
CGFloat scale = 2;
size.height *= scale;
size.width *= scale;
UIGraphicsBeginImageContextWithOptions(size, NO, 0.0);
NSArray *frames = [HEYDAY.collagePhotoFrames framesForCollageType:collageType
boundingSize:size];
if (frames.count > 1) {
[frames enumerateObjectsUsingBlock:^(NSValue *rectValue, NSUInteger idx, BOOL *stop) {
CGRect rect = rectValue.CGRectValue;
if (idx == highlightedIndex) {
[highlightedFillColor set];
} else {
[fillColor set];
}
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect
cornerRadius:1*scale];
[path fill];
}];
} else {
if (0 == highlightedIndex) {
[highlightedFillColor set];
} else {
[fillColor set];
}
CGRect rect = CGRectInset((CGRect){CGPointZero, size}, 2.0, 2.0);
UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:rect
cornerRadius:1*scale];
[path fill];
}
UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return image;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment