I created a UIButton instance named "button" with an image using [UIButton setImage:forState:]
. The button.frame is larger than the image's size.
Now I want to scale this button's image smaller. I tried changing button.imageView.frame
, button.imageView.bounds
and button.imageView.contentMode
, but all seem ineffective.
Can anyone help me scale a UIButton
's imageView?
I created the UIButton
like this:
UIButton *button = [[UIButton alloc] init];
[button setImage:image forState:UIControlStateNormal];
I tried to scale the image like this:
button.imageView.contentMode = UIViewContentModeScaleAspectFit;
button.imageView.bounds = CGRectMake(0, 0, 70, 70);
and this:
button.imageView.contentMode = UIViewContentModeScaleAspectFit;
button.imageView.frame = CGRectMake(0, 0, 70, 70);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…