Skip to content

Instantly share code, notes, and snippets.

@primalmotion
Created October 26, 2010 14:25
Show Gist options
  • Select an option

  • Save primalmotion/646992 to your computer and use it in GitHub Desktop.

Select an option

Save primalmotion/646992 to your computer and use it in GitHub Desktop.
- (void)init
{
if (self = [super init])
{
// ...
_toolbarSelection = [[CPImageView alloc] initWithFrame:CPRectMake(0,0,46,57)];
[_toolbarSelection setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin];
[_toolbarSelection setBackgroundColor:[CPColor blueColor]];
// ...
}
return self;
}
// ...
- (void)setMainToolbar:(CPToolbar)aToolbar
{
_mainToolbar = aToolbar;
[_mainToolbar._toolbarView addSubview:_toolbarSelection positioned:CPWindowBelow relativeTo:nil];
}
- (IBAction)didToolbarModuleClicked:(id)sender
{
// ...
//hack code for the background on the toolbarItem
var selectionFrame = [_toolbarSelection frame],
toolbarView = _mainToolbar._toolbarView,
subviews = [toolbarView subviews],
index = 0,
count = [subviews count];
for (; index < count; ++index)
{
var toolbarItemView = subviews[index];
// if ([toolbarItemView._toolbarItem tag] === @"Personal")
// break;
}
//console.log(toolbarItemView);
var frame = [toolbarItemView convertRect:[toolbarItemView bounds] toView:_mainToolbar._toolbarView];
[_toolbarSelection setFrameOrigin:CGPointMake(CGRectGetMinX(frame) + (CGRectGetWidth(frame) - CGRectGetWidth(selectionFrame)) / 2.0, 0.0)];
//end of hack
// ...
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment