Guest User

Untitled

a guest
Jun 19th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. - (void)init
  2. {
  3. if (self = [super init])
  4. {
  5. // ...
  6. _toolbarSelection = [[CPImageView alloc] initWithFrame:CPRectMake(0,0,46,57)];
  7. [_toolbarSelection setAutoresizingMask:CPViewMinXMargin | CPViewMaxXMargin];
  8. [_toolbarSelection setBackgroundColor:[CPColor blueColor]];
  9. // ...
  10. }
  11.  
  12. return self;
  13. }
  14.  
  15. // ...
  16.  
  17. - (void)setMainToolbar:(CPToolbar)aToolbar
  18. {
  19. _mainToolbar = aToolbar;
  20. [_mainToolbar._toolbarView addSubview:_toolbarSelection positioned:CPWindowBelow relativeTo:nil];
  21. }
  22.  
  23.  
  24. - (IBAction)didToolbarModuleClicked:(id)sender
  25. {
  26. // ...
  27. //hack code for the background on the toolbarItem
  28. var selectionFrame = [_toolbarSelection frame],
  29. toolbarView = _mainToolbar._toolbarView,
  30. subviews = [toolbarView subviews],
  31. index = 0,
  32. count = [subviews count];
  33.  
  34. for (; index < count; ++index)
  35. {
  36. var toolbarItemView = subviews[index];
  37.  
  38. // if ([toolbarItemView._toolbarItem tag] === @"Personal")
  39. // break;
  40. }
  41. //console.log(toolbarItemView);
  42. var frame = [toolbarItemView convertRect:[toolbarItemView bounds] toView:_mainToolbar._toolbarView];
  43.  
  44. [_toolbarSelection setFrameOrigin:CGPointMake(CGRectGetMinX(frame) + (CGRectGetWidth(frame) - CGRectGetWidth(selectionFrame)) / 2.0, 0.0)];
  45. //end of hack
  46.  
  47. // ...
  48.  
  49. }
Add Comment
Please, Sign In to add comment