Reputation: 449
CustomView *customView = [[CustomView alloc] init];
[self.window.contentView addSubview:customView];
How can i make customView.frame.size.height
always equals to contentView.frame.size.height
when the window resize , and at the same time customView.frame.size.width = 20;
?
Upvotes: 6
Views: 8665
Reputation: 6537
Swift version, to apply autoresizingMask:
let customView = CustomView()
customView.autoresizingMask = [.width, .height]
self.window.contentView.addSubview(customView)
Upvotes: 12
Reputation: 122391
Set the custom view's autoresizingMask:
CustomView *customView = [[CustomView alloc] init];
customView.autoresizingMask = NSViewWidthSizable | NSViewHeightSizable;
[self.window.contentView addSubview:customView];
Upvotes: 9