Resizing a UIButton programmatically by maintaining a margin
- by Oscar Del Ben
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.