我试图给我的UIButton一个新的背景图像,当用户按下按钮,然后动画的宽度。问题是该按钮不能缩放图像(我只使用视网膜图像)。UIButton背景图像缩放比例错误
点击之前:
后点击:
这使事情代码发生:
UIImage *buttonProfileDefault = [[UIImage imageNamed:@"Profile_Button_Default"] resizableImageWithCapInsets:UIEdgeInsetsMake(3, 3, 3, 3)];
[self.profileButton setBackgroundImage:buttonProfileDefault forState:UIControlStateNormal];
[self.profileButton removeConstraint:self.profileButtonConstraint];
// Animate
CGRect originalFrame = self.profileButton.frame;
originalFrame.size.width = 40;
[UIView animateWithDuration:0.2f
animations:^{
self.profileButton.frame = originalFrame;
}
completion:^(BOOL finished) {
}];
我希望我们能想出解决办法:我有同样的问题。我已经尝试了所有contentMode选项和所有imageEdgeInsets(对于那些将我的背景图像移动到按钮图像中,覆盖或消除按钮标题)的所有都无济于事。 – tobinjim
我会为此付出代价。真的需要知道它。 –
@HolgerEdwardWardlowSindbæk尝试我的代码... –