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

标签 objective-c ios xcode

我想调整按钮所在位置的大小并延迟它,你能帮我吗? (发件人=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/

相关文章:

swift - SourceView 和 SourceRect 被贬值了吗?

iPhone 唯一的应用程序被拒绝,因为它是通用二进制文件

objective-c - 如何在 iOS/Objective C 中获取 TouchPoint 的坐标和像素颜色

objective-c - 尝试使用 NSXMLParser 解析格式不正确的 XML

iphone - UILocalNotification 操作和暂停

ios - 如何对 graphQL 模式进行比设置时创建的更进一步的更改?

iphone - 在 iOS 应用程序中使用 .mdb 文件而不是 SQLite?

ios - 'NSInvalidArgumentException',原因 : '*** -[__NSPlaceholderDictionary initWithObjects:forKeys:count:]: attempt to insert nil object from objects[3]'

iphone - 防止 iPhone 缩放表格?

swift - 如何在第一个 UITest 失败时中止 FaSTLane Scan 测试