// 将像素point由point所在视图转换到目标视图view中,返回在目标视图view中的像素值
- (CGPoint)convertPoint:(CGPoint)point toView:(UIView *)view;
// 将像素point从view中转换到当前视图中,返回在当前视图中的像素值
- (CGPoint)convertPoint:(CGPoint)point fromView:(UIView *)view;
// 将rect由rect所在视图转换到目标视图view中,返回在目标视图view中的rect
- (CGRect)convertRect:(CGRect)rect toView:(UIView *)view;
// 将rect从view中转换到当前视图中,返回在当前视图中的rect
- (CGRect)convertRect:(CGRect)rect fromView:(UIView *)view;
一个小Demo演示上面其中一个的用法
//放大动画效果
CGRect frame = [self convertRect:self.bounds toView:self.window];
_fullImageView.frame = frame;
[UIView animateWithDuration:0.3
animations:^{
_fullImageView.frame = [UIScreen mainScreen].bounds;
}
completion:^(BOOL finished) {
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];
_scrollView.backgroundColor = [UIColor blackColor];
if (self.urlstring.length > 0)
{
_progressView.hidden = NO;
}else
{
_progressView.hidden = YES;
}
}];
//缩小的动画效果
[UIView animateWithDuration:.3
animations:^{
_fullImageView.frame = [self convertRect:self.bounds toView:self.window];
}
completion:^(BOOL finished) {
[_scrollView removeFromSuperview];
//释放视图
_scrollView = nil;
_fullImageView = nil;
_progressView = nil;
//取消网络请求
[_connection cancel];
}];