I'm configuring a view with some push buttons and other views programmatically 
and the buttons are drawn offset to the right.
For example, the first button should be at 0,20 but it is drawn at 6,20. I 
checked that the buttons are not moved, the button frames remain the same, the 
buttons are just drawn 6 points to the right.

Here's a screenshot: https://s3.amazonaws.com/mellel.outbox/button_woes.png

Here's the code:

NSView* _view = [_window contentView];
CGFloat position;

position = 0;
for (NSString* buttonTitle in @[@"button one",@"button two",@"button three"])
{
NSButton* button;

button = [[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 0, 0)];
[button setTranslatesAutoresizingMaskIntoConstraints:NO];
[button setBezelStyle:NSRoundedBezelStyle];
[button setTitle:buttonTitle];
[button sizeToFit];
[button setFrameOrigin:NSMakePoint(position, 20)];
[_view addSubview:button];
position += [button frame].size.width + 8;
}

Thanks in advance,

Eyal Redler
------------------------------------------------------------------------------------------------
"If Uri Geller bends spoons with divine powers, then he's doing it the hard 
way."
--James Randi
www.eyalredler.com


_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to