我需要它左对齐。或者没有办法,我需要添加自定义标签?如何更改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 - 如何更改标签栏的位置项目
你不希望它为中心? –