Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (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
- // ...
- }
Add Comment
Please, Sign In to add comment