Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use NSTitlebarAccessoryViewController?

Can anyone tell me how to use NSTitlebarAccessoryViewController, to add subview to a view with an example? As I am new to mac programming you may have to explain from basics. Please.

like image 621
sharmada Avatar asked Jan 28 '15 08:01

sharmada


People also ask

What is the angular @viewchild decorator?

The Angular @ViewChild decorator is one of the first decorators that you will run into while learning Angular, as it's also one of the most commonly used decorators. This decorator has a lot of features: some of them might not be very well known but they are extremely useful.

Can @viewchild decorator see across component boundaries?

Angular interprets `color-sample` as ColorSampleComponent, just like any other Angular component of directive in the template. `color-sample` is defined as the selector of ColorSampleComponent (in the component class). "The @ViewChild decorator cannot see across component boundaries!" What is a "component boundary"?

What is @viewchild in Salesforce?

@ViewChild is a local component template querying mechanism, that cannot see the internals of its child components. By injecting references directly into our component class, we can easily write any coordination logic that involves multiple elements of the template.


1 Answers

NSTitlebarAccessoryViewController is for adding subviews to the windows title bar.

Here is a example: Set up a view in interface builder. Go to the `applicationDidFinishLaunching: method to add the view to the title bar.

The code would be the following:

NSTitlebarAccessoryViewController* vc = [[NSTitlebarAccessoryViewController alloc] init];

vc.view = self.view;
vc.layoutAttribute = NSLayoutAttributeRight;

[self.window addTitlebarAccessoryViewController:vc];

You can play with the size of the view to make it fit into the title bar.

Update

OS X 10.11 introduced the new layoutAttribute left. There are now three layoutAttributes in total. bottom adds a bar beneath the titleBar (like the tabBar) and left/right places your subview within the titleBar.

like image 99
mangerlahn Avatar answered Oct 01 '22 21:10

mangerlahn