Created
June 20, 2014 21:53
-
-
Save saniul/00daf8cc04e5bda20059 to your computer and use it in GitHub Desktop.
UIBezierPath Bug
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
+ (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