custom controls
play

Custom Controls from Scratch Douglas Heriot /dev/world/2012 - PowerPoint PPT Presentation

Custom Controls from Scratch Douglas Heriot /dev/world/2012 @DouglasHeriot http://douglasheriot.com/ Why? How? NSWindow NSTitledWindowMask NSTitledWindowMask | NSTexturedBackgroundWindowMask NSBorderlessWindowMask


  1. Custom Controls from Scratch Douglas Heriot /dev/world/2012 @DouglasHeriot http://douglasheriot.com/

  2. Why?

  3. How?

  4. NSWindow

  5. NSTitledWindowMask

  6. NSTitledWindowMask | NSTexturedBackgroundWindowMask

  7. NSBorderlessWindowMask

  8. NSBorderlessWindowMask -setOpaque:NO

  9. NSWindow

  10. NSWindow NSView

  11. -[NSWindow contentView] -[NSWindow setContentView:]

  12. -drawRect:

  13. Let’s do that

  14. NSTableView

  15. Hundreds of subviews?

  16. NSWindow NSView NSCell Used by NSView to perform drawing and handle events.

  17. NSView - (void)drawRect:(NSRect)dirtyRect

  18. NSView - (void)drawRect:(NSRect)dirtyRect NSCell - (void)drawWithFrame:(NSRect)frame inView:(NSView *)controlView

  19. Scrolling? NSScrollView -copiesOnScroll

  20. How do we fix all this?

  21. Core Animation Introduced in OS X 10.5

  22. Layers

  23. Code?

  24. Layer-backed view Layer-hosting view - (id)initWithFrame:(NSRect)frame - (id)initWithFrame:(NSRect)frame { { if ([super initWithFrame:frame]) if ([super initWithFrame:frame]) { { self.layer = [CALayer layer]; self.wantsLayer = YES; self.wantsLayer = YES; } } return self; return self; } } CALayer created automatically. You own the CALayer – Don’t touch! do whatever you want.

  25. Layer Properties

  26. backgroundColor

  27. cornerRadius

  28. border

  29. shadow

  30. contents

  31. CAGradientLayer

  32. iOS Much nicer. All views are layer-backed.

  33. Table views? Layer-backed views, stored in a reuse queue.

  34. Performance

  35. OS X Still has the old legacy way.

  36. Using more views is now recommended.

  37. View-based table views

  38. 9-slice scaling

  39. Where do you start? • Sketch on paper • Mockup in Photoshop • Separate logical moving pieces • Bitmaps & CA Layer properties • Event handling

  40. Douglas Heriot http://douglasheriot.com/ douglas@douglasheriot.com @douglasheriot University of Wollongong

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend