title: Custom view for NSPopupButton NSMenu
body: <p>I'm having some problems setting a custom NSView for my NSPopupButton menu items. Here is what I've got so far:</p>
  
  <pre><code>@interface ViewController ()
  
  @property (weak) IBOutlet NSPopUpButton *popupButton;
  
  @end
  
  @implementation ViewController
  
  - (void)viewDidLoad {
      [super viewDidLoad];
  
      for(int i = 0; i &lt; 25; i++) {
          NSMenuItem *menuItem = [[NSMenuItem alloc ] initWithTitle:[NSString stringWithFormat:@"%d", i] action:@selector(itemClicked:) keyEquivalent:@""];
  
          MenuView  *menuView = [[MenuView alloc] initWithFrame:CGRectMake(0, 0, 184, 50)];
          menuView.displayText.stringValue = @"This is a test";
  
          [menuItem setView:menuView];
          [self.popupButton.menu addItem:menuItem];
      }
  }
  
  - (void)itemClicked:(id)sender {
  
  }
  
  @end
  </code></pre>
  
  <p>//My custom view</p>
  
  <pre><code>@implementation MenuView
  - (id)initWithFrame:(NSRect)frameRect {
      NSString* nibName = NSStringFromClass([self class]);
      self = [super initWithFrame:frameRect];
      if (self) {
          if ([[NSBundle mainBundle] loadNibNamed:nibName
                                            owner:self
                                  topLevelObjects:nil]) {
              [self configureView];
          }
      }
      return self;
  }
  
  - (void)awakeFromNib {
      [super awakeFromNib];
      [self configureView];
  }
  
  - (void)configureView {
      [self setWantsLayer:YES];
      self.layer.backgroundColor = [NSColor blueColor].CGColor;
  }
  
  
  @end
  </code></pre>
  
  <p>//Here is what my xib MenuView looks like </p>
  
  <p><a href="https://i.stack.imgur.com/rjvYG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rjvYG.png" alt="enter image description here"></a></p>
  
  <p>And here is the problem:</p>
  
  <p><a href="https://i.stack.imgur.com/BSTyq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BSTyq.png" alt="enter image description here"></a></p>
  
  <p>This seems like it should be a fairly straight forward task but I'm not sure what is happening to my view and why my label on the view seems to disappear and is not showing any text for each of the views. I was poking around in the documentation and stumbled across this for the NSPopupButton Menu :</p>
  
  <pre><code>// Overrides behavior of NSView.  This is the menu for the popup, not a context menu.  PopUpButtons do not have context menus.
  @property (nullable, strong) NSMenu *menu;
  </code></pre>
  
  <p>I'm not sure if there is something that I'm doing wrong that is causing this problem or if what I'm trying to do in this context is not achievable off of an NSPopupButton NSMenu. If anyone has any experience with this and could offer advice I'd really appreciate it. </p>