仿照微博首页中间加号后弹出按钮的设计,我的实例:
UIButton *button = [[UIButtonalloc] initWithFrame:CGRectMake(100,100, 100,50)];
button.backgroundColor = [UIColorredColor];
[self.viewaddSubview:button];
[UIViewanimateWithDuration:1delay:0.5usingSpringWithDamping:0.3initialSpringVelocity:0.6options:UIViewAnimationOptionCurveEaseInOutanimations:^{
button.frame =CGRectMake(100,400, 100,50);
} completion:^(BOOL finished) {
}];
它的方法是:
+ (void)animateWithDuration:(NSTimeInterval)duration delay:(NSTimeInterval)delay usingSpringWithDamping:(CGFloat)dampingRatio initialSpringVelocity:(CGFloat)velocity options:(UIViewAnimationOptions)options animations:(void (^)(void))animations completion:(void (^__nullable)(BOOL finished))completion
参数解析:
duration