iphone - 如何使图像像在 iPhone 主屏幕上一样摇摆不定?

标签 iphone objective-c ios core-animation

我的应用程序中有很多图标,我想以类似于您尝试从 iPhone 主屏幕删除应用程序时发生的方式为它们制作动画。你怎么能这样做?

此外,有没有办法让图标以类似于解锁 iPhone 时发生的方式动画化到屏幕上?

最佳答案

如果你想让你的 View 、图像等像主屏幕一样摇摆不定,你可以这样做:

    CGAffineTransform leftWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-15.0));
    CGAffineTransform rightWobble = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(15.0));

    view.transform = leftWobble;  // starting point

    [UIView beginAnimations:@"wobble" context:view];
    [UIView setAnimationRepeatAutoreverses:YES];
    [UIView setAnimationRepeatCount:5]; // adjustable
    [UIView setAnimationDuration:0.125];
    [UIView setAnimationDelegate:self];
    view.transform = rightWobble; // end here & auto-reverse
    [UIView commitAnimations];

您还需要添加此定义:

#define RADIANS(degrees) ((degrees * M_PI) / 180.0)

关于iphone - 如何使图像像在 iPhone 主屏幕上一样摇摆不定?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4980122/

相关文章:

android - Moodle Rest Console API 成绩

objective-c - iOS 应用仅在某些随机设备上引发 0x8badf00d

iphone - 在实现文件中重复类接口(interface)声明有什么意义?

ios - 如何在 Swift 中复制/复制自定义 collectionview 单元格?

iphone - 在 iOS 设备上禁用应用外视频

iphone - CGFloat的乘除法和精度损失

iphone - UINavigationBar 和返回按钮的自定义

iphone - 如何在 UITableView 中为自定义单元格使用 UISearchBar

ios - 自定义获取核心数据(快速)

javascript - 应用程序中的 Meteor 服务器端渲染