Created
October 26, 2010 14:25
-
-
Save primalmotion/646992 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| - (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