Re: Programmatically created NSButton is drawn in the wrong position.
Re: Programmatically created NSButton is drawn in the wrong position.
- Subject: Re: Programmatically created NSButton is drawn in the wrong position.
- From: Ben Kennedy via Cocoa-dev <email@hidden>
- Date: Mon, 14 Dec 2020 18:05:00 -0800
> On 14 Dec 2020, at 5:39 pm, Eyal Redler via Cocoa-dev
> <email@hidden> wrote:
>
> 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)];
Since you're positioning the frames manually, you need to set
setTranslatesAutoresizingMaskIntoConstraints = YES instead of NO.
-ben
_______________________________________________
Cocoa-dev mailing list (email@hidden)
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:
This email sent to email@hidden