Skip to content

Instantly share code, notes, and snippets.

@odrobnik
Created February 28, 2014 12:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save odrobnik/9269916 to your computer and use it in GitHub Desktop.
Save odrobnik/9269916 to your computer and use it in GitHub Desktop.
NSUInteger BCKCodeMaxBarScaleThatFitsCodeInSize(BCKCode *code, CGSize size, NSDictionary *options)
{
NSInteger retScale = 1;
NSMutableDictionary *mutableOptions = [NSMutableDictionary dictionaryWithDictionary:options];
for (NSUInteger scale=1;;scale++)
{
mutableOptions[BCKCodeDrawingBarScaleOption] = @(scale);
CGSize neededSize = [code sizeWithRenderOptions:mutableOptions];
if (neededSize.width > size.width || neededSize.height > size.height) {
return retScale;
}
retScale = scale;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment