Resizing a UIButton programmatically by maintaining a margin
Posted
by
Oscar Del Ben
on Stack Overflow
See other posts from Stack Overflow
or by Oscar Del Ben
Published on 2011-01-02T09:50:03Z
Indexed on
2011/01/02
9:53 UTC
Read the original article
Hit count: 323
cocoa-touch
Hello, I'm adding a UIButton to a tableView footer programmatically. This button has a left and right margin that is equal to the tableView margin:
UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
deleteButton.frame = CGRectMake(10, 60, 300, 34);
deleteButton.autoresizingMask = UIViewAutoresizingFlexibleWidth
I'm adding autoresizingMask because I want to support rotation. However, it does not work as I want, as the button stretches all the way down to the right, as shown by the image below.
Any idea how to fix it? If I remove the autosizing property then the margin is correct.
© Stack Overflow or respective owner