先布局完 - 延时方法,设置缩放比例;
CGRect bgFrame = self.bgView.frame;
bgFrame.size = CGSizeMake(2*maxRadiusOfX,2*maxRadiusOfY+300);
self.bgView.frame = bgFrame;
self.mainScrollView.contentSize = CGSizeMake(2*maxRadiusOfX,2*maxRadiusOfY+300);
[self.mainScrollView setContentOffset:CGPointMake((self.mainScrollView.contentSize.width-kScreenWidth)/2,(self.mainScrollView.contentSize.height-self.view.height)/2) animated:YES];
[self drawKnowledgeTree:self.parentItem.layerReq withCenterPoint:CGPointMake(maxRadiusOfX, (maxRadiusOfY+150)) startAngle:0 radius:60 isShow:YES];
[self performSelector:@selector(delaySetZoomScale) withObject:nil afterDelay:0.5];
``
-(void)delaySetZoomScale{
[self.mainScrollView setZoomScale:0.3 animated:YES];
}
``
缩放完,代理回调设置视图在中心位置;
``
pragma mark - UIScrollViewDelegate
(UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView{
NSLog(@"开始缩放");
return self.bgView;
}-
(void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(CGFloat)scale {
if (!self.isFirstScale) {
self.isFirstScale = YES;
[self.mainScrollView setContentOffset:CGPointMake((self.mainScrollView.contentSize.width-kScreenWidth)/2,(self.mainScrollView.contentSize.height-self.view.height)/2) animated:YES];
}
}
``