2011-04-07 1 views
1

라벨을 이동하고 크기를 조정하려하지만 라벨의 크기가 즉시 조정 된 다음 위치가 변경됩니다. 먼저 주석 처리 된 lbl.frame 줄을 간단히 시도했습니다. 다음으로이 질문에 발견iPad - 라벨 이동 및 크기 조정 방법

How to animate while resizing UIView

을 그리고 contentMode을 제외하고 다른 모든 코드를 추가. 이것은 내가 원했던 것이었지만 레이블의 글꼴이 축소되면서 아래쪽으로 조정되지 않았습니다. (나는 xib에 맞도록 조정한다). 마지막으로 contentMode 행을 추가하면 원래 프레임 선과 동일한 결과를 얻었습니다. 즉, 먼저 축소하여 처음으로 움직이게합니다.

lbl.contentMode = UIViewContentModeRedraw; 
    [UIView animateWithDuration:1.0 delay:0.0 
         options:(UIViewAnimationOptionAllowUserInteraction) 
        animations:^{ 
         //lbl.frame = CGRectMake(x, mStartingLine.frame.origin.y+mStartingLine.frame.size.height, 100, 100); 
         CGRect theBounds = lbl.bounds; 
         CGPoint theCenter = lbl.center; 
         theBounds.size.height = 100; 
         theBounds.size.width = 100; 
         theCenter.y = mStartingLine.frame.origin.y+mStartingLine.frame.size.height+50; 
         theCenter.x = x; 
         lbl.bounds = theBounds; 
         lbl.center = theCenter; 
        } 
        completion:nil 
    ]; 

답변

1

자동 텍스트 크기 조정 기능이 Core Animation에서 작동하지 않는다고 생각됩니다.

내가 제안하는 것은 레이블을 최종 크기 (경계를 사용하여)로 설정 한 다음 변환을 적용하여 다시 시작 크기로 축소하는 것입니다. 이러한 것들의 최종 효과는 동일한 크기로 유지되어야한다는 것입니다.

마지막으로 animateWithDuration : animations :를 사용하여 뷰 변형을 ID 변환으로 다시 설정하여 새로운 크기로 확장합니다.

이것이 어떤 인위적인 인공물이 될지 모르겠다. 시도해야 할 것이다.