views:

96

answers:

1

I have the following code.

  UIImage *cancelImg = [UIImage imageNamed:@"cancel.jpeg"]; 
  UIButton *btnCancel = [UIButton buttonWithType:UIButtonTypeCustom];
  btnCancel.userInteractionEnabled = YES;
  [btnCancel setFrame:CGRectMake(0.0,0.0, 28.0, 28.0)];
  [btnCancel setImage:cancelImg forState:UIControlStateNormal];
  cell.accessoryView  = btnCancel;

cancel.jpeg currently is bigger than 28 x 28 and it's actually 100 x 100.

Why does the button display 100 x 100 size of the image when I've set the UIButton's size to 28 x 28?

+2  A: 

The image of the button will not be rescaled. Set as the backgroundImage if you need rescaling.

[btnCancel setBackgroundImage:cancelImg forState:UIControlStateNormal];
KennyTM