按钮滑动的动画效果 我现在想实现这样的效果,一个按钮平滑地从一个位置滑动到另一个位置,请问这个可以通过动画效果实现吗?具体要怎么做呢,谢谢! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 + (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0, completion = NULL这三个动画函数即可。把按钮的frame改变一下。 我使用了如下代码,实现每次点击背景,按钮平滑移动,但是只有第一次点击的时候按钮是平滑地移动。- (void)move{ __block CGRect rect = button.frame; [UIView animateWithDuration:0.5 animations:^{ //button.transform = CGAffineTransformMakeRotation(3.14); button.transform = CGAffineTransformMakeTranslation(20, 20); } completion:^(BOOL finished){ rect.origin.x+=20; rect.origin.y+=20; button.frame = rect; }];}- (IBAction)bkTap:(id)sender{ [self move];} fOffsetX,fOffsetY表示移动的话,代码这么写就对了:fOffsetX+=20;fOffsetY+=20;CGAffineTransformMakeTranslation(fOffsetX, fOffsetY); soga。。受教了! 想做个答题的应用 希望高手给个思路~ ipad上开发遇到的问题 关于NSThread 内存管理疑问 ios 输入方向问题 苹果开发 IOS7 tableView被navigationBar挡住了 iOS 类名前缀, 个人喜好? ios开发问题 16进制字符串转ascii码 利用 runtime,解决多次点击相同 button,导致重复跳转的问题 ipad可以远程连接Linux服务器么 ios segue
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0);+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations completion:(void (^)(BOOL finished))completion __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0+ (void)animateWithDuration:(NSTimeInterval)duration animations:(void (^)(void))animations __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_4_0); // delay = 0.0, options = 0, completion = NULL这三个动画函数即可。把按钮的frame改变一下。
{
__block CGRect rect = button.frame;
[UIView animateWithDuration:0.5
animations:^{
//button.transform = CGAffineTransformMakeRotation(3.14);
button.transform = CGAffineTransformMakeTranslation(20, 20);
}
completion:^(BOOL finished){
rect.origin.x+=20;
rect.origin.y+=20;
button.frame = rect;
}];
}
- (IBAction)bkTap:(id)sender
{
[self move];
}
fOffsetX+=20;
fOffsetY+=20;
CGAffineTransformMakeTranslation(fOffsetX, fOffsetY);