|  | @@ -11,14 +11,12 @@
 | 
	
		
			
			| 11 | 11 |  @interface RCCCustomTitleView ()
 | 
	
		
			
			| 12 | 12 |  @property (nonatomic, strong) UIView *subView;
 | 
	
		
			
			| 13 | 13 |  @property (nonatomic, strong) NSString *subViewAlign;
 | 
	
		
			
			| 14 |  | -@property float initialWidth;
 | 
	
		
			
			| 15 | 14 |  @end
 | 
	
		
			
			| 16 | 15 |  
 | 
	
		
			
			| 17 | 16 |  @implementation RCCCustomTitleView
 | 
	
		
			
			| 18 | 17 |  
 | 
	
		
			
			| 19 | 18 |  
 | 
	
		
			
			| 20 | 19 |  -(instancetype)initWithFrame:(CGRect)frame subView:(UIView*)subView alignment:(NSString*)alignment {
 | 
	
		
			
			| 21 |  | -    _initialWidth = frame.size.width;
 | 
	
		
			
			| 22 | 20 |      self = [super initWithFrame:frame];
 | 
	
		
			
			| 23 | 21 |      
 | 
	
		
			
			| 24 | 22 |      if (self) {
 | 
	
	
		
			
			|  | @@ -54,56 +52,4 @@
 | 
	
		
			
			| 54 | 52 |      }
 | 
	
		
			
			| 55 | 53 |  }
 | 
	
		
			
			| 56 | 54 |  
 | 
	
		
			
			| 57 |  | -- (void)setFrame:(CGRect) frame {
 | 
	
		
			
			| 58 |  | -
 | 
	
		
			
			| 59 |  | -    float referenceWidth = [self statusBarWidth];
 | 
	
		
			
			| 60 |  | -    if (referenceWidth == 0) {
 | 
	
		
			
			| 61 |  | -        referenceWidth = _initialWidth;
 | 
	
		
			
			| 62 |  | -    }
 | 
	
		
			
			| 63 |  | -    float newNavBarWidth = frame.size.width;
 | 
	
		
			
			| 64 |  | -    BOOL frameNeedsToBeCorrected = newNavBarWidth < referenceWidth || CGRectEqualToRect(self.frame, CGRectZero);
 | 
	
		
			
			| 65 |  | -
 | 
	
		
			
			| 66 |  | -    if (frameNeedsToBeCorrected) {
 | 
	
		
			
			| 67 |  | -        // first we need to find out the total point diff of the status bar and the nav bar
 | 
	
		
			
			| 68 |  | -        float navBarHorizontalMargin = referenceWidth - newNavBarWidth;
 | 
	
		
			
			| 69 |  | -        
 | 
	
		
			
			| 70 |  | -        CGRect correctedFrame = frame;
 | 
	
		
			
			| 71 |  | -
 | 
	
		
			
			| 72 |  | -        // then we need to place the nav bar half times the horizontal margin to the left
 | 
	
		
			
			| 73 |  | -        correctedFrame.origin.x = -(navBarHorizontalMargin / 2);
 | 
	
		
			
			| 74 |  | -        
 | 
	
		
			
			| 75 |  | -        // and finally set the width so that it's equal to the status bar width
 | 
	
		
			
			| 76 |  | -        correctedFrame.size.width = referenceWidth;
 | 
	
		
			
			| 77 |  | -        
 | 
	
		
			
			| 78 |  | -        [super setFrame:correctedFrame];
 | 
	
		
			
			| 79 |  | -    } else if (frame.size.height != self.frame.size.height) { // otherwise
 | 
	
		
			
			| 80 |  | -        // if only the height has changed
 | 
	
		
			
			| 81 |  | -        CGRect newHeightFrame = self.frame;
 | 
	
		
			
			| 82 |  | -        // make sure we update just the height
 | 
	
		
			
			| 83 |  | -        newHeightFrame.size.height = frame.size.height;
 | 
	
		
			
			| 84 |  | -        [super setFrame:newHeightFrame];
 | 
	
		
			
			| 85 |  | -    }
 | 
	
		
			
			| 86 |  | -    
 | 
	
		
			
			| 87 |  | -    // keep a ref to the last frame, so that we avoid setting the frame twice for no reason
 | 
	
		
			
			| 88 |  | -//    _lastFrame = frame;
 | 
	
		
			
			| 89 |  | -}
 | 
	
		
			
			| 90 |  | -
 | 
	
		
			
			| 91 |  | -
 | 
	
		
			
			| 92 |  | -- (void) viewWillTransitionToSize:(CGSize)size withTransitionCoordinator:(id<UIViewControllerTransitionCoordinator>)coordinator {
 | 
	
		
			
			| 93 |  | -    // whenever the orientation changes this runs
 | 
	
		
			
			| 94 |  | -    // and sets the nav bar item width to the new size width
 | 
	
		
			
			| 95 |  | -    CGRect newFrame = self.frame;
 | 
	
		
			
			| 96 |  | -
 | 
	
		
			
			| 97 |  | -    if (newFrame.size.width < size.width) {
 | 
	
		
			
			| 98 |  | -        newFrame.size.width = size.width;
 | 
	
		
			
			| 99 |  | -        newFrame.origin.x = 0;
 | 
	
		
			
			| 100 |  | -    }
 | 
	
		
			
			| 101 |  | -    [super setFrame:newFrame];
 | 
	
		
			
			| 102 |  | -}
 | 
	
		
			
			| 103 |  | -
 | 
	
		
			
			| 104 |  | --(float) statusBarWidth {
 | 
	
		
			
			| 105 |  | -    CGSize statusBarSize = [[UIApplication sharedApplication] statusBarFrame].size;
 | 
	
		
			
			| 106 |  | -    return MAX(statusBarSize.width, statusBarSize.height);
 | 
	
		
			
			| 107 |  | -}
 | 
	
		
			
			| 108 |  | -
 | 
	
		
			
			| 109 | 55 |  @end
 |