Tag: uibaritem

导航栏不显示在故事板中

我在导航控制器中embedded了一个viewController,导航栏项目显示(在大纲编辑器),我可以改变标题,但导航栏没有显示在(大纲编辑器),因此我不能改变酒吧色彩的颜色。 所以我尝试以编程方式添加在导航栏中,如下所示: .h file @property (strong, nonatomic) UINavigationBar *nav; .m file nav = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, 320, 50)]; self.nav.tintColor = [UIColor blueColor]; [self.view addSubview:nav]; 结果如下: 更新

摆脱UINavigationBar右侧的空间

所以,这是我想要完成的: 这是一个带有UIBarButtonItem的UINavigationBar ,它使用自定义的UIButton进行初始化。 基本上是这样的: UIButton *favoriteButton = [UIButton buttonWithType:UIButtonTypeCustom]; [favoriteButton addTarget:target action:action forControlEvents:UIControlEventTouchUpInside]; favoriteButton.frame = CGRectMake(0.0f, 0.0f, 44.0f, 44.0f); UIImage *backgroundImage = [[UIImage imageNamed:@"favorite-button-background-orange"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 2, 0, 0)]; [favoriteButton setBackgroundImage:backgroundImage forState:UIControlStateNormal]; UIBarButtonItem *favoriteButtonItem = [[UIBarButtonItem alloc] initWithCustomView:favoriteButton]; 问题是我似乎无法摆脱UINavigationBar右侧的那个讨厌的小边框。 我试图设置一个自定义TitleView ,如“ 如何删除UIBarButtonItem旁边的填充 ”中所述,但这并没有改变一件事情。 我也尝试添加另一个UIBarButtonItem与消极的宽度(正如我读的一些博客文章中所build议的),但是也没有帮助。 UIBarButtonItem *negativeSpacer = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; negativeSpacer.width = -5.0f; self.navigationItem.rightBarButtonItems […]

你如何在UIBarItem中使用setTitleTextAttributes:forState?

你如何使用setTitleTextAttributes:forState:在iOS中的UIBarItem ? 你如何设置NSDictionary ? 不能让它工作,文件不是很清楚。 从文档: setTitleTextAttributes:forState: 为给定的控制状态设置标题的文本属性: – (void)setTitleTextAttributes:(NSDictionary *)attributes forState:(UIControlState)state 参数: attributes(属性):包含文本属性的键值对的字典。 您可以使用NSString UIKit Additions Reference中列出的键来指定字体,文字颜色,文字阴影颜色和文字阴影偏移量。 状态:要为其设置标题文本属性的控件状态。