Skip to content

Instantly share code, notes, and snippets.

@pita5
Created December 17, 2011 15:24
Show Gist options
  • Save pita5/1490483 to your computer and use it in GitHub Desktop.
Save pita5/1490483 to your computer and use it in GitHub Desktop.
- (void)doLayout
{
if (_data)
{
NSMutableArray *frameArray = [[_data objectForKey:@"rects"] mutableCopy];
id toRemove = nil;
for (NSMutableDictionary *info in frameArray)
{
if (![[info objectForKey:@"selectable"] boolValue])
{
NSMutableDictionary *infoCopy = [info mutableCopy];
CGRect infoRect = CGRectFromString([infoCopy objectForKey:@"rect"]);
CGPathRef textPath = CGPathCreateWithRect(infoRect, NULL);
CGMutablePathRef mutPath = CGPathCreateMutableCopy(textPath);
[infoCopy setObject:(id)mutPath
forKey:@"path"];
CGPathRelease(textPath);
CGPathRelease(mutPath);
[self setBaseFrame:infoCopy];
toRemove = info;
}
}
if (_baseFrame)
{
CGMutablePathRef _baseFramePath = (CGMutablePathRef)[_baseFrame objectForKey:@"path"];
[frameArray removeObject:toRemove];
for (NSMutableDictionary *info in frameArray)
{
CGRect infoRect = CGRectFromString([info objectForKey:@"rect"]);
CGPathRef textPath = CGPathCreateWithRect(infoRect, NULL);
[info setObject:(id)textPath forKey:@"path"];
if (![[info objectForKey:@"floating"] boolValue])
{
CGPathAddPath(_baseFramePath, NULL, textPath);
}
}
}
CGMutablePathRef _baseFramePath = (CGMutablePathRef)[_baseFrame objectForKey:@"path"];
NSMutableArray *points = [NSMutableArray array];
CGPathApply(_baseFramePath, points, clipApplier);
[self setFrames:frameArray];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment