era*_*orx 6 iphone core-animation
您是否有AppStore价格的UIButton动画的示例代码 - >购买按钮.我尝试了很多,但它不能很好地与CAAnimationGroup(缩放+转换)一起使用,并且它只能在UIView beginAnimations中将其设置为新的帧大小.动画首先设置新的宽度(立即)然后设置新的原点..所以它不是正确的效果......
谢谢!
您是否在Core Animation块中进行了更改?
我创建了一个简单的基于视图的iPhone应用程序来测试它.该视图有两个圆角矩形UIButton对象:
第一个按钮位于右上角,宽度为62(高度为35),初始标题为"$ 0.99".它连接到视图控制器中的"按钮"插座和"动画"动作.这是在点击时将动画的按钮.
第二个按钮位于屏幕底部,标题为"重置",并连接到视图控制器中的"重置"操作.
这是视图控制器代码:
UIButtonAnimationTestViewController.h:
#import <UIKit/UIKit.h>
@interface UIButtonAnimationTestViewController : UIViewController {
IBOutlet UIButton *button;
CGRect originalFrame;
}
- (IBAction)animate;
- (IBAction)reset;
@end
Run Code Online (Sandbox Code Playgroud)
UIButtonAnimationTestViewController.m:
#import "UIButtonAnimationTestViewController.h"
@implementation UIButtonAnimationTestViewController
- (void)viewDidLoad {
[super viewDidLoad];
originalFrame = button.frame;
}
- (IBAction)animate {
CGRect frame = button.frame;
frame.origin.x -= 30;
frame.size.width += 30;
[UIView beginAnimations:@"button" context:nil];
button.frame = frame;
[button setTitle:@"" forState:UIControlStateNormal];
[UIView setAnimationDelegate:self];
[UIView commitAnimations];
}
- (void)animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context {
[button setTitle:@"BUY NOW" forState:UIControlStateNormal];
}
- (IBAction)reset {
button.frame = originalFrame;
[button setTitle:@"$0.99" forState:UIControlStateNormal];
}
Run Code Online (Sandbox Code Playgroud)