iphone - 如何改变UINavigationBar的标签位置(frame)?

标签 iphone ios xcode cocoa uinavigationbar

我需要它左对齐。或者没有办法,我需要添加自定义标签?

最佳答案

将其添加到左侧按钮项:

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];

关于iphone - 如何改变UINavigationBar的标签位置(frame)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10868668/

相关文章:

iphone - 通过蓝牙通信的 iOS5 Bonjour 的 DNSServiceRegister 和 DNSServiceBrowse 示例

iOS 在后台或应用程序激活时执行预定操作

ios - 合并 AppDelegate_iPhone 和 AppDelegate_iPad

ios - UILabel 文本颜色更改

ios - cordova 应用程序文件夹中没有 .xcodeproj 文件

iphone - 从字符串 '2011-08-16T19:03:21.000Z' 获取日期

iphone - 使用 CNContactStore 以编程方式将家庭地址保存到新联系人?雨燕3

iphone - No type or storage class may be specified here before 'interface'/'interface' iOS 错误(损坏的 Xcode?)

ios - 标签不显示 Swift 中计时器的值

ios 使用自动布局在另一个 View 中放置 3 个 View