Hol*_*bæk 6 iphone xcode objective-c storyboard ios
当用户按下按钮然后设置宽度动画时,我试图给我的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) {
}];
Run Code Online (Sandbox Code Playgroud)
我也遇到了同样的问题,但它发生在我的应用程序加载时,我在检查器中搞乱了 的button属性,如果您向下滚动并取消选中autoresize subviews它可能会起作用,它对我有用!
| 归档时间: |
|
| 查看次数: |
2629 次 |
| 最近记录: |