Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
  2. // Insert code here to initialize your application
  3. NSScrollView *scrollView = [[NSScrollView alloc] init];
  4. [self.window.contentView addSubview:scrollView];
  5. [scrollView setFrame:NSMakeRect(0, 0, self.window.contentView.frame.size.width, self.window.contentView.frame.size.height)];
  6. [scrollView setHasHorizontalScroller:YES];
  7.  
  8. NSView *documentView = [[NSView alloc] initWithFrame:NSMakeRect(0, 0, 1000, scrollView.frame.size.height)];
  9. [documentView setWantsLayer:YES];
  10. [documentView.layer setBackgroundColor:[NSColor redColor].CGColor];
  11. [scrollView setDocumentView:documentView];
  12.  
  13. NSView *aView = [[NSView alloc] initWithFrame:NSMakeRect(10, 10, 30, 30)];
  14. aView.layer.backgroundColor = [NSColor blueColor].CGColor;
  15. [aView setWantsLayer:YES];
  16. [aView setNeedsLayout:YES];
  17. [aView setNeedsDisplay:YES];
  18. [scrollView addSubview:aView];
  19. //What I really want is [scrollView addFloatingSubview:aView forAxis:NSEventGestureAxisHorizontal]; but since the `addSubview` doesn't work, so the problem is not at the floating stuff.
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement