Saturday, September 3, 2011

How to place button on title Bar?


#import <Foundation/Foundation.h>




@interface uiview : NSObject {
IBOutlet NSWindow *mainWindow;
IBOutlet NSView *accessoryView;


}


// Methods
- (void)composeInterface;
-(IBAction)button : (id)sender;




@end

#import "uiview.h"




@implementation uiview

- (void)awakeFromNib
{
[self composeInterface];
[mainWindow setTitleWithRepresentedFilename:@"/Users/parag/Documents/UIview"];
}






- (void)composeInterface
{
NSView *themeFrame = [[mainWindow contentViewsuperview];
NSRect c = [themeFrame frame];  
NSRect aV = [accessoryView frame];
NSRect newFrame = NSMakeRect(
c.size.width - aV.size.width,   // x position
c.size.height - aV.size.height// y position NSPoint
aV.size.width,  // width
aV.size.height);        // height //NSSize
[accessoryView setFrame:newFrame];

[themeFrame addSubview:accessoryView];
}