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: Keary Suska via Cocoa-dev <email@hidden>
- Date: Tue, 15 Dec 2020 08:24:24 -0700
Based on what you are doing, setting the property to YES will get you closer to
what your problem is. When this property is NO, you cannot accurately control
the view’s frame.
That being said, when are you verifying that the frame of the buttons is
unchanged?
Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"
> On Dec 15, 2020, at 3:49 AM, Eyal Redler via Cocoa-dev
> <email@hidden> wrote:
>
> setting translatesAutoresizingMaskIntoConstraints to yes makes the situation
> worse. The buttons are drawn further away than their frames indicate.
>
> Eyal
>
>> On 15 Dec 2020, at 4:05, Ben Kennedy <email@hidden> wrote:
>>
>>
>>> 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
_______________________________________________
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