我正在尝试为按钮设置动画,使其增长以填充屏幕,保持然后收缩到其原始位置。我有动画工作正常,然而,有一些奇怪的。按钮标题或图像内容不随按钮缩放,而是移动到屏幕的右下角,然后向按钮中心移动,然后当按钮缩小时,它们再次从按钮移开。
是否有可能使按钮的标题始终保持在中心?我也试过更改内容拉伸但是这会使模拟器崩溃。
-(void) animateButton:(UIButton *)card{
[self.view bringSubviewToFront:card];
CGRect tempFrame = CGRectMake(...);
CGRect curFrame = [card getFrame];
[UIView animateWithDuration:.5 delay: 0.0 options: UIViewAnimationOptionCurveEaseIn animations:^
{
[card setFrame:tempFrame];
//[card setContentStrech:tempFrame];
}completion:^(BOOL finished)
{
[UIView animateWithDuration:.5 delay: 1.0 options:UIViewAnimationOptionCurveEaseOut animations:^
{
[card setFrame:curFrame];
//[card setContentStrech:curFrame];
}completion:nil];
}];
}
答案 0 :(得分:1)
您应该为Transform属性设置动画,而不是框架属性。
(你会看到像素,除非你从一个大按钮和缩小的大字体开始)