2013-11-04 2 views
3

내가 앱이 활성화 될 때 특정 수직 탐색 모음의 제목 오프셋을 설정 설정 :탐색 모음의 모양이 후 변경하지 않는 첫 번째

[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-3.0f forBarMetrics:UIBarMetricsDefault]; 

그런 다음, 나중에 탐색 계층 구조에서, 내가 설정해야 다른 수직 오프셋 때문에 다음과 같이 호출합니다.

[[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-0.5f forBarMetrics:UIBarMetricsDefault]; 

하지만 앱을 탐색 할 때 새로운 수직 오프셋이 적용되지 않습니다. 그러나 앱이 비활성 상태로 다시 활성화되면 다시 적용됩니다. 앱이 포 그라운드에서 유지되는 동안 어떻게이 오프셋을 변경할 수 있습니까?

감사합니다.

답변

0

애니메이션 블록을 사용하여 이것을 시도 했습니까? 뷰 윈도우를 들어갈 때

[UIView animateWithDuration:3 
      animations:^{ 
          [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-3.0f forBarMetrics:UIBarMetricsDefault]; 
          [[UINavigationBar appearance] setTitleVerticalPositionAdjustment:-0.5f forBarMetrics:UIBarMetricsDefault]; 
        }]; 
+0

감사합니다. 방금 시도했지만 작동하지 않습니다 ... iOS 7에서 테스트 중이므로 다른 방식으로해야합니까? – AppsDev

0

https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UIAppearance_Protocol/index.html

에서 아이폰 OS는이 창에 이미 뷰의하지 변화 모양을 수행, 외관 변경 사항을 적용합니다. 현재 창에있는보기의 모양을 변경하려면보기 계층에서 보기를 제거한 다음 다시 넣습니다.

그래서 기본적으로 당신은 ...보기를 제거하고 즉시 다시 이런 일을 추가 할 몇 가지 해킹을 할 필요가

UIView *currentview = ((AppDelegate*)[UIApplication sharedApplication].delegate).window.rootViewController.view; 
UIView *superview = currentview.superview; 
[currentview removeFromSuperview]; 
[superview addSubview:currentview]; 

그리고 스위프트에 대한

...

if let currentview = (UIApplication.sharedApplication().delegate as? AppDelegate)?.window?.rootViewController?.view { 
    if let superview = currentview.superview { 
     currentview.removeFromSuperview() 
     superview.addSubview(currentview) 
    } 
}