#96 new
Rich Collins

CPButton sizeToFit doesn't consider margins

Reported by Rich Collins | October 8th, 2008 @ 09:53 AM



_okButton = [[CPButton alloc] initWithFrame:CPRectMake(0, 0, 0, 0)];
  [_okButton setTarget:_target];
  [_okButton setAction:_action];
  [_okButton setFont:[CPFont fontWithName:"Helvetica" size:16]];
  [_okButton setTitle:"OK"];
  [_okButton sizeToFit];
  [_okButton setFrameOrigin:CPPointMake(
      CPRectGetWidth([self bounds]) / 2 - CPRectGetWidth([_okButton bounds]) / 2,
      CPRectGetHeight([self bounds]) - Margin - CPRectGetHeight([_okButton bounds])
    )
  ];
  [self addSubview:_okButton];

See attached image for result

No comments found

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

The Cappuccino Web Framework, including AppKit, Foundation, and Objective-J.

Shared Ticket Bins

People watching this ticket

Attachments

Pages