gpt4 book ai didi

objective-c - Objective C 按钮调整大小和延迟

转载 作者:塔克拉玛干 更新时间:2023-11-02 20:20:03 27 4
gpt4 key购买 nike

我想在它所在的位置重新调整按钮的大小并延迟它,你能帮我吗?(发件人=UIButton)

我的功能:

-(IBAction)Animate: (id) sender
{

[sender setBackgroundImage:[UIImage imageNamed:@"Text Bg large.png"] forState:UIControlStateNormal];
CABasicAnimation *scale;
scale = [CABasicAnimation animationWithKeyPath:@"transform.scale"];
scale.fromValue = [NSNumber numberWithFloat:1];
scale.toValue = [NSNumber numberWithFloat:1.3];
scale.duration = 1;
scale.removedOnCompletion = NO;

scale.repeatCount = 1;
[sender addAnimation:scale forKey:@""];
[sender setFrame:(CGRectMake(x, y, z, w))];


}

如果我希望按钮保持在同一位置并且在不手动输入值的情况下增大 1.3 倍,我应该为 x、y、z、w 使用什么。哦,我怎么能延迟这个操作呢?

最佳答案

您使用 CAAnimation 执行此操作是否有任何原因?

怎么样:

CGRect newFrame = CGRectInset(sender.frame, CGRectGetWidth(sender.frame) * -0.15, CGRectGetHeight(sender.frame) * -0.15);

[UIView animateWithDuration: 1.0
delay: 0.5
options: UIViewAnimationOptionCurveLinear
animations:^{
[sender setFrame: newFrame];
}
completion: nil];

[UIView animateWithDuration: 1.0
delay: 0.5
options: UIViewAnimationOptionCurveLinear
animations:^{
[sender setTransform: CGAffineTransformMakeScale(1.3, 1.3)];
}
completion: nil];

关于objective-c - Objective C 按钮调整大小和延迟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12277299/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com