我需要它左對齊。或者沒有辦法,我需要添加自定義標籤?如何更改UINavigationBar的標籤位置(框架)?
2
A
回答
0
我發現我自己的解決方案:
float offset = 210.0f;
UIToolbar* tools = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, offset, 44.01)];
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:tools];
[tools release];
0
2
將它添加到左邊的按鈕項:
UIView *mCustView = [[UIView alloc] initWithFrame:CGRectMake(0,0,200,20)];
mCustView.backgroundColor = [UIColor redColor];
UILabel *mTextLabel = [[UILabel alloc] initWithFrame:CGRectMake(0,0,200,20)];
mTextLabel.backgroundColor = [UIColor blueColor];
mTextLabel.font = [UIFont systemFontOfSize:20];
mTextLabel.textColor = [UIColor blackColor];
mTextLabel.text = @"Random text tested here, so sit back and enjoy";
[mCustView addSubview:mTextLabel];
[mTextLabel release];
UIBarButtonItem *mCustomBarItem = [[UIBarButtonItem alloc] initWithCustomView:mCustView];
self.navigationItem.leftBarButtonItem = mCustomBarItem;
[mCustView release];
1
我想你可以使用UIBarButtonSystemItemFixedSpace
提供增加的一種方式導航欄中的固定填充:
UIBarButtonItem *fixedSpaceItem = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace
target:nil
action:NULL]
autorelease];
fixedSpaceItem.width = 50;
UIBarButtonItem *cancelItem = [[[UIBarButtonItem alloc]
initWithBarButtonSystemItem:UIBarButtonSystemItemCancel
target:nil
action:NULL]
autorelease];
// vc is some view controller
vc.navigationItem.leftBarButtonItems = [NSArray arrayWithObjects:
fixedSpaceItem,
cancelItem,
nil];
This will righ t縮進「取消」按鈕50分。
+0
這是如何回答我的問題??? – nik
+0
對不起,我誤解了你的問題,認爲你想改變左邊或右邊項目的縮進。 –
相關問題
- 1. 如何更改TTLauncherItem的文本標籤框架/位置
- 2. 如何更改UINavigationBar的位置?
- 3. UINavigationBar - 如何更改UIBarButtonItem的位置?
- 4. 如何更改標籤的位置
- 5. 如何更改標籤位置?
- 6. 如何更改圖表標籤上的小數點並更改標籤位置?
- 7. 更改UINavigationBar後臺的backarrow位置
- 8. PHP的頭位置更改父框架
- 9. 如何更改UINavigationBar標題標籤大小?
- 10. 改變位置在UINavigationBar的
- 11. 更改DOM中標籤的位置
- 12. 更改UICollectionViewCell中的標籤位置
- 13. 更改Chart.js打勾標籤的位置
- 14. 更改clabel的位置和標籤
- 15. 如何更改自定義UINavigationBar類的標籤文本
- 16. 在jQuery中更改框架位置
- 17. 如何更改自定義MKAnnotationView的框架位置?
- 18. 更改標籤和文本框的位置
- 19. 更改UINavigationBar的標題
- 20. 更改iOS BarChart xAxis標籤位置
- 21. 更改JSSOR圖片標籤位置
- 22. 更改當前位置標籤文本
- 23. 如何更改WPF中的tabcontrol中的標籤項位置
- 24. 改變gganimate框架標題的標籤
- 25. 如何更改文本框的位置
- 26. 如何更改UINavigationBar標題而不更改UITabBar標題?
- 27. 如何更改UINavigationController的UINavigationBar?
- 28. 如何更改Telerik RadTimeBar標籤的位置?
- 29. 如何更改Xaml AppBarButton(Windows UWP)的標籤位置
- 30. Xcode - 如何更改標籤欄的位置項目
你不希望它爲中心? –