Skip to content

Instantly share code, notes, and snippets.

@tolmasky
Created June 5, 2009 21:49
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 tolmasky/124533 to your computer and use it in GitHub Desktop.
Save tolmasky/124533 to your computer and use it in GitHub Desktop.
//this is the view i use to show the selection:
_toolbarSelection = [[CPImageView alloc] initWithFrame:CGRectMake(0.0, 0.0, 50.0, 57.0)];
[_toolbarSelection setImage:MediaWindowControllerToolbarSelectionImage];
[_toolbarSelection setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin];
// Here comes the hack:
[myWindow._toolbarView addSubview:_toolbarSelection];
// Upon clicking on the button, we do this to position it:
var selectionFrame = [_toolbarSelection frame],
toolbarView = [[[self window] toolbar] _toolbarView],
subviews = [toolbarView subviews],
index = 0,
count = [subviews count];
for (; index < count; ++index)
{
var toolbarItemView = subviews[index];
if ([toolbarItemView tag] === aTag)
break;
}
var frame = [toolbarItemView convertRect:[toolbarItemView bounds] toView:[self window]._toolbarView];
[_toolbarSelection setFrameOrigin:CGPointMake(CGRectGetMinX(frame) + (CGRectGetWidth(frame) - CGRectGetWidth(selectionFrame)) / 2.0, 28.0)];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment