代碼1:
UIBarButtonItem * item = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStylePlain
target:self action:@selector(exits)];
//[item setBackgroundVerticalPositionAdjustment:10.0f forBarMetrics:UIBarMetricsDefault];
self.navBar.topItem.leftBarButtonItem = item;
[[UIBarButtonItem appearance] setBackgroundVerticalPositionAdjustment:+5 forBarMetrics:UIBarMetricsDefault];
代碼2:
UIBarButtonItem * item = [[UIBarButtonItem alloc] initWithTitle:@"Back"
style:UIBarButtonItemStylePlain
target:self action:@selector(exits)];
//[item setBackgroundVerticalPositionAdjustment:10.0f forBarMetrics:UIBarMetricsDefault];
self.navBar.topItem.leftBarButtonItem = item;
[[UIBarButtonItem appearance] setTitlePositionAdjustment:UIOffsetMake(0, 50) forBarMetrics:UIBarMetricsDefault];
我都嘗試了上面的代碼並沒有工作
我想要什麼要做的是回到UIBarButtonItem下移我的例子標題的水平。 如何做到這一點。
的XCode 5.1.1似乎並不接受這一點。需要訪問「contentVerticalAlignment」和「contentEdgeInsets」的庫導入嗎? –