Skip to content

Commit

Permalink
Fix the title label position bug in iPhone6 and iPhone6 Plug.
Browse files Browse the repository at this point in the history
  • Loading branch information
xhzengAIB committed Feb 11, 2015
1 parent 553bb25 commit 958d783
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions XHTwitterPaggingViewer/Views/XHPaggingNavbar.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,11 @@

#define kXHLabelBaseTag 1000

@interface XHPaggingNavbar ()
#define kXHRadie 3.2

@interface XHPaggingNavbar () {
CGFloat _mainScreenWidth;
}

/**
* 分页指示器
Expand Down Expand Up @@ -42,7 +46,7 @@ - (void)reloadData {
}];

[self.titles enumerateObjectsUsingBlock:^(NSString *title, NSUInteger idx, BOOL *stop) {
CGRect titleLabelFrame = CGRectMake((idx * (kXHiPad ? 240 : 100)), 8, CGRectGetWidth(self.bounds), 20);
CGRect titleLabelFrame = CGRectMake((idx * (kXHiPad ? 240 : _mainScreenWidth / kXHRadie)), 8, CGRectGetWidth(self.bounds), 20);
NSInteger tag = kXHLabelBaseTag + idx;
UILabel *titleLabel = (UILabel *)[self viewWithTag: tag];
if (!titleLabel) {
Expand Down Expand Up @@ -94,7 +98,7 @@ - (void)setContentOffset:(CGPoint)contentOffset {

// frame
CGRect titleLabelFrame = titleLabel.frame;
titleLabelFrame.origin.x = (idx * (kXHiPad ? 240 : 100)) - xOffset / 3.2;
titleLabelFrame.origin.x = (idx * (kXHiPad ? 240 : _mainScreenWidth / kXHRadie)) - xOffset / kXHRadie;
titleLabel.frame = titleLabelFrame;

// alpha
Expand Down Expand Up @@ -137,6 +141,8 @@ - (id)initWithFrame:(CGRect)frame {
if (self) {
// Initialization code
self.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
_mainScreenWidth = [[UIScreen mainScreen] bounds].size.width;

[self addSubview:self.pageControl];
}
return self;
Expand Down

0 comments on commit 958d783

Please sign in to comment.