Tag: uitoolbar

自定义UINavigationController UIToolbar的子类

我需要在UINavigationController使用一个子类UIToolbar 。 我知道这可以通过Interface Builder来完成,但是我需要通过编程来完成。 该文档声明, UINavigationController工具栏属性是只读的,所以我有点在我如何继续的损失。 有关: 自定义的UINavigationController UIToolbar背景图片

UIBarButtonItem不能在UIToolBar中单击

我有一个UIPickerView ,我添加了2个UIBarButtonItems 。 var toolBar = UIToolbar() toolBar.frame.origin.y = -40 toolBar.barStyle = UIBarStyle.Default toolBar.translucent = true toolBar.tintColor = UIColor(red: 76/255, green: 217/255, blue: 100/255, alpha: 1) toolBar.sizeToFit() var doneButton = UIBarButtonItem(title: "Done", style: UIBarButtonItemStyle.Bordered, target: self, action: "donePicker") var spaceButton = UIBarButtonItem(barButtonSystemItem: UIBarButtonSystemItem.FlexibleSpace, target: nil, action: nil) var cancelButton = UIBarButtonItem(title: "Cancel", style: UIBarButtonItemStyle.Bordered, target: […]

iOS为什么已经将ToolBar与键盘间隔开了

我想通过出现的键盘如何移动我的工具栏与button和文本字段: – (void) liftMainViewWhenKeybordAppears:(NSNotification*)aNotification { NSDictionary* userInfo = [aNotification userInfo]; NSTimeInterval animationDuration; UIViewAnimationCurve animationCurve; CGRect keyboardFrame; [[userInfo objectForKey:UIKeyboardAnimationCurveUserInfoKey] getValue:&animationCurve]; [[userInfo objectForKey:UIKeyboardAnimationDurationUserInfoKey] getValue:&animationDuration]; [[userInfo objectForKey:UIKeyboardFrameBeginUserInfoKey] getValue:&keyboardFrame]; [UIView beginAnimations:nil context:nil]; [UIView setAnimationDuration:animationDuration]; [UIView setAnimationCurve:animationCurve]; [self.navigationController.toolbar setFrame:CGRectMake(self.navigationController.toolbar.frame.origin.x, self.navigationController.toolbar.frame.origin.y – keyboardFrame.size.height +self.navigationController.toolbar.frame.size.height, self.navigationController.toolbar.frame.size.width, self.navigationController.toolbar.frame.size.height)]; [UIView commitAnimations]; } 一切工作正常,但移动的工具栏和键盘之间有一个小的差距: 我无法弄清楚这个问题? 可能是什么问题或者是预期的行为? 谢谢!

为所创build的UIToolbar设置UIToolbarPosition

我正在编写仅针对iOS5设备的应用程序,因此我正试图最大限度地利用新appearance API。 我可以用下面的方法改变我的UIToolbar背景: [[UIToolbar appearance] setBackgroundImage:<myImage> forToolbarPosition:UIToolbarPositionAny barMetrics:UIBarMetricsDefault]; 一切工作正常,但我正在寻找更多的定制,所以我想知道UIToolbarPosition用法,我遇到了一些问题。 使用InterfaceBuilder或以编程方式添加UIToolbar我将其定位在主视图的顶部 – 所以我期待UIToolbarPosition被设置为UIToolbarPositionTop ,但是从我testing它不能自动工作,也不能find任何API允许我设置UIToolbarPosition (是的,我已经Googlesearch了)。 所以 – 主要问题 – 如何创buildUIToolbar并正确标记,所以它只能响应UIToolbarPositionTop或UIToolbarPositionBottom ,所以我可以使用: [[UIToolbar appearance] setBackgroundImage:<myImage_1> forToolbarPosition:UIToolbarPositionTop barMetrics:UIBarMetricsDefault]; [[UIToolbar appearance] setBackgroundImage:<myImage_2> forToolbarPosition:UIToolbarPositionBottom barMetrics:UIBarMetricsDefault]; 编辑:更多细节,如问。 我的应用程序中增加了多个工具栏,例如,两个屏幕上的屏幕顶部的工具栏,作为键盘附件视图的工具栏和模态屏幕底部的2个工具栏。 我想最大限度地利用新的外观API,而不是在每个屏幕上自定义工具栏,因此我问了整个UIToolbarPosition的东西,以及如何使用它。 我知道我可以通过自定义每个UIToolbar来实现我想要的function,但是我只是对新的API和UIToolbarPosition的使用感到好奇。

iOS – 和UIToolbars

我一直试图在UIToolbar中使用[UIColor clearColor] ,试图使一个自定义的控制界面更适合一个“机械”应用程序(Thinkbutton,你会看到在70年代的电影)。 发生什么事情是,当我设置清除颜色的工具栏是它变成哑黑色。 背后的图像是红色,棕褐色和黑色,所以我确信它不能按预期工作。 我看到的一个区别是,我使用导航控制器上的工具栏,而不是一个独立的UIToolbar 。 代码行是 self.navigationController.toolbar.translucent = YES; self.navigationController.toolbar.backgroundColor = [UIColor clearColor]; 和我的上部导航栏(这是在另一个视图中设置)是UIBarStyleBlackTranslucent ,这可以把它扔掉吗? 任何帮助追踪这将是很大的。

可以在导航栏中为UIBarButtonItem设置背景图像,但不能在底部工具栏中设置背景图像

所以这项工作时,将项目添加到导航栏,但是当我通过界面生成器添加到设置在底部栏中的工具栏,背景图像不显示。 UIBarButtonItem *resetButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"Reset" style:UIBarButtonItemStylePlain target:self action:@selector(resetCriteria:)]; UIImage *img = [UIImage imageNamed:@"someImage.png"]; img = [img stretchableImageWithLeftCapWidth:5 topCapHeight:20]; [resetButtonItem setBackgroundImage:img forState:UIControlStateNormal barMetrics:UIBarMetricsDefault]; self.toolbarItems = [NSArray arrayWithObjects: resetButtonItem, nil]; 不仅背景不会出现,其他行为也不会起作用(但将这些barbutton项添加到导航栏时,它们可以正常工作)

iOS – 更改UIBarButtonItem的高度

UIToolbar有一个很好的selectresize(self.navigationController.toolbar.frame)我想知道是否有人知道的方式来更改UIBarButtonItem的高度? 我有一个高度为117像素的自定义工具栏,到目前为止,我还没有find一种方法来修改工具栏上的button。 此外,我需要它是一个工具栏,因为显示的视图被另一个animation视图(剪切场景样式)覆盖,而我在第一个视图中设置资产,工具栏需要保持在所有的顶部。

自动布局iOS 11工具栏与customView的UIBarButtonItem

最近在我们的项目中,使用customView的UIBarButtonItem存在问题。 在iOS 11之前,我们通过灵活的间距项目进行了布局。 这不起作用,所以什么也没有显示。 因为我在这里没有find答案,真正解决了我的问题,所以我研究了一下,并提出了一个我想与大家分享的(一种可靠的解决scheme)解决scheme。 也许它可以帮助你,或者你有一些反馈。 这是混合objc和swift代码,希望你不介意。

UIToolbarresize导致景观中奇怪的UIBarButtonItem大小

当我创build并添加UIToolBar和UIBarButton项目时,如何让工具栏和项目在两个方向上正确显示。 这是我迄今为止: self.toolbar = [[[UIToolbar alloc]initWithFrame:CGRectMake(0, 372, 320, 44)]autorelease]; self.toolbar.autoresizingMask = UIViewAutoresizingFlexibleTopMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight; self.deleteButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemTrash target:self action:@selector(deleteButtonClicked)] autorelease]; self.deleteButton.style = UIBarButtonItemStylePlain; UIBarButtonItem *flexibleSpace = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil] autorelease]; self.shareButton = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAction target:self action:@selector(shareButtonClicked)] autorelease]; self.shareButton.style = UIBarButtonItemStylePlain; self.navigationItem.leftBarButtonItem = backItem; NSArray *toolbarItems = [NSArray arrayWithObjects:self.shareButton,flexibleSpace,self.deleteButton,nil]; […]

当UIActionSheet改变视图时,工具栏项目消失

从UIActionSheetbutton启动视图时,在通过导航栏后退button返回到视图时,仍然可见的工具栏上没有任何之前的button。 自从升级到iOS 6后,出现此错误,并且仅在运行iOS 6的模拟器和设备上进行testing。 如果我注释掉隐藏在UIActionSheet推送的视图上的工具栏的代码,则在返回时添加button。 我正在viewWillAppear编程我的工具栏项目,并显示我通过self.navigationController.toolbar访问工具栏的UIActionSheet 。 任何想法是什么导致这个问题? 这只是自iOS 6已经出现,所以有什么变化,我需要考虑到viewWillAppear ? 这是如何从actionSheet推送视图: – (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (actionSheet.tag == 2) { if (buttonIndex == 0) { [self dismissAllTips]; self.actionNoteAddView= [[self.storyboard instantiateViewControllerWithIdentifier:@"IDActionNoteAddView"] retain]; actionNoteAddView.note_id = 0; actionNoteAddView.iscompleted=0; [[NSUserDefaults standardUserDefaults] setBool:NO forKey:@"tool_tips"]; [self.navigationController pushViewController:actionNoteAddView animated:TRUE]; [actionNoteAddView release]; }else if(buttonIndex == 1){ … 这些是推送视图的视图方法: -(void)viewWillAppear:(BOOL)animated{ [super viewWillAppear:animated]; […]