Bạn còn có thể chuyển cái nhìn của bạn với hình ảnh động trơn tru như
này
- (void)moveViewPosition:(CGFloat)xPosition forView:(UIView *)view
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.2];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[view setFrame:CGRectMake(xPosition, view.frame.origin.y,view.frame.size.width, view.frame.size.height)];
[UIView commitAnimations];
}
và gọi nó như thế này
để biết thêm bạn cũng có thể sửa đổi nó để vượt qua thời gian yêu cầu của bạn trên cuộc gọi chức năng như thế này.
- (void)moveViewPosition:(CGFloat)xPosition forView:(UIView *)view withDuration:(float)duration;
có những lựa chọn khác như
UIView* view = [self.view viewWithTag:99999];
[UIView animateWithDuration:0.9
delay:0.0
options: UIViewAnimationCurveEaseOut
animations:^
{
CGRect frame = view.frame;
frame.origin.y = 68;
frame.origin.x = 0;
view.frame = frame;
}
completion:^(BOOL finished)
{
NSLog(@"Completed");
}];
công trình đối với tôi, cho các tùy chọn tốt hơn để sử dụng: UIViewAnimationOptionCurveEaseOut – TharakaNirmana