你可以在这里看到:
http://www.screencast.com/t/mSveqUgPe1类似于我这里的问题:UIBarButtonItem自定义背景外观'后翻转过渡
这似乎完全是由通过外观api为UIBarButtonItem
设置自定义字体引起的。
[[UIBarButtonItem appearance] setTitleTextAttributes:
[NSDictionary dictionaryWithObjectsAndKeys:
[UIColor colorWithRed:1 green:1 blue:1 alpha:1.0],
UITextAttributeTextColor,
[UIColor colorWithRed:4/255.0 green:4/255.0 blue:4/255.0 alpha:0.5],
UITextAttributeTextShadowColor,
[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeTextShadowOffset,
[UIFont fontWithName:@"ProximaNova-Bold" size:16.0],
UITextAttributeFont,
nil] forState:UIControlStateNormal];
如果我注释掉,即使只是字体部分,它解决了问题。即使使用像Helvetica这样的非自定义字体,在以这种方式设置时也会导致相同的问题。之前调整图像偏移量的方法在这个图像上不起作用,所以尝试找到另一个解决方法。
显然这是一个bug,但是这次我在代码中找到了一个新的解决方法。
- (void)viewWillLayoutSubviews {
[super viewWillLayoutSubviews];
self.navigationItem.rightBarButtonItem.title = @"NEXT";
}
调用super viewWillLayoutSubviews
后用代码设置标题有效。至于为什么会这样……不知道。
不是
现在它在跳。它呈现错误,然后更新到正确的位置/大小。