2011-05-11 3 views
5

내 이미지 뷰를 하위 뷰로로드하는 UIView가 있습니다. 앵커 포인트를 설정하지 않았을 때 이미지가 표시되지만 앵커 포인트를 설정할 때마다 이미지가 표시되지 않습니다. QUARTZCore 프레임도 추가되었습니다.앵커 포인트를 설정하면 이미지가로드되지 않습니다.

나는 문제는

CGRect apprect=CGRectMake(0, 0, 1024, 768); 
UIView *containerView = [[UIView alloc] initWithFrame:apprect1]; 
containerView.backgroundColor = [UIColor whiteColor]; 
[self.view addSubview:containerView]; 

handleView1= [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"large.gif"]]; 
[handleView1 setAlpha:1]; 
//[handleView1 setFrame:CGRectMake(390, 172.00, 56.00, 316.00)]; 
handleView1.userInteractionEnabled = YES; 
handleView1.layer.anchorPoint=CGPointMake(490.0, 172.0); 
[containerView addSubview:handleView1]; 

답변

6

아래 당신이 anchorPoint에 사용하는 값을 내 코드를하는 추가하고있다. 프레임의 위치와 같은 점을 값으로 설정하지 마십시오. 내가 애플을 인용 보자 :

anchorPoint 속성은 위치 좌표를 함께 를 해당 레이어의 범위 내에서 위치를 지정하는 CGPoint 이다. 앵커 포인트는 경계가 위치 속성과 관련하여 배치되는 방식과 을 변환 지점이 으로 적용되는 방식으로 지정하는 방법을 지정합니다. 단위 좌표계 (0.0,0.0) 값이 레이어의 원점에 가장 가까이 위치하고 (1.0,1.0)가 반대 구석에있는 인 단위 좌표계에서 으로 표현됩니다.

enter image description here

은 자세한 내용은 Layer Geometry and Transforms in the Core Animation Programming Guide에서보세요.

+0

Nick Weaver 정말 고마워. 고마워. – Lena

0

우선하여 이미지 뷰의 프레임을 설정하고이

같은 ancherpoint 설정 [handleView1.layer setAnchorPoint : CGPointMake (1, 1)];

관련 문제