//这里关键的地方是把view的y坐标设到屏幕下方
/** objective-c代码*/
let aView = UIView.init();
let yOffset = UIScreen.main().bounds.height;
let yTargetOffset = 200; //你想要最终放置的y坐标
let originalRect = CGRect.init(x: 0, y: yOffset, width: 100, height: 200);
let targetRect = CGRect.init(x: 0, y: yTargetOffset, width: 100, height: 200);
//初始位置
aView.frame = originalRect;
//动画
UIView.animate(withDuration: 0.3) {
//赋值最终位置
aView.frame = targetRect;
}
/** oc代码*/
UIView *aView = [UIView new];
CGFloat yOffset = [UIScreen mainScreen].bounds.size.height; //初始y值
CGFloat yTargetOffset = 200; //目标y值
CGRect originalRect = CGRectMake(0, yOffset, 100, 200);
CGRect targetRect = CGRectMake(0, yTargetOffset, 100, 200);
//初始位置
aView.frame = originalRect;
//动画
[UIView animateWithDuration:.3 animations:^{
aView.frame = targetRect;
}];