草庐IT

UINavigationBar

全部标签

ios - 为左右按钮设置自定义 UINavigationBar 图像

这是我的Storyboard:我想更改两个按钮图像。我有一张13x46的图像,但在将其用作按钮图像时遇到问题。我四处搜索了一些代码,但我对它们并不是很成功。有什么想法吗? 最佳答案 这是非常简单的事情,只需alloc/initWithImage几个条形按钮项,然后应用它们。UIBarButtonItem*leftItem=[[UIBarButtonItemalloc]initWithImage:[UIImageimageNamed:@"myImage"]style:UIBarButtonItemStyleBorderedtarget

ios - UINavigationBar setTitleTextAttributes 带下划线文本

我正在尝试使用此代码在所有View中使用下划线setTextAttribute[[UINavigationBarappearance]setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColorredColor],//NSUnderlineStyleAttributeName:@(NSUnderlineStyleSingle),(NSString*)kCTUnderlineStyleAttributeName:@(kCTUnderlineStyleDouble),NSFontAttributeName:[UIFontf

iphone - 在 ViewController 中设置 UINavigationBar 背景图片

我可以使用以下代码在应用委托(delegate)didFinishLaunchingWithOptions方法中将导航栏的背景设置为自定义图像:UIImage*navBarImage;navBarImage=[UIImageimageNamed:@"navbar.png"];[[UINavigationBarappearance]setBackgroundImage:navBarImageforBarMetrics:UIBarMetricsDefault];我试图在我的应用程序中添加一个选项,以在切换开关时更改导航栏的背景图像,但它似乎不起作用。是否只能在应用启动时设置背景图片?在应用

ios - 防止 UINavigationBar popViewController 动画

我有以下问题:我已经覆盖了UINavigationController的popViewControllerAnimated:(BOOL)animated因为我想要自定义动画。代码如下:-(UIViewController*)popViewControllerAnimated:(BOOL)animated{UIViewController*poppedCtrl=[superpopViewControllerAnimated:NO];[((customViewController*)self.topViewController)doCustomAnimation];returnpopped

iOS 7 改变 UINavigationBar titleView alpha

所以我使用的是iOS7的UINavigationBar组件,而不是UINavigationController本身。当我使用自定义导航Controller推送新View时,我想将标题的alpha更改为0.0然后再更改回来,但我似乎无法让它工作。我正在尝试这样做vc1.navBar.topItem.titleView.alpha=0.1;好像没什么效果。我在这里遗漏了什么吗?有没有正确的方法来实现这一目标? 最佳答案 我会这样做:在推送的viewController的viewWillAppear:中,我会使用以下方法将它的alpha设

ios - 以编程方式向 UINavigationBar 添加后退按钮?

我正在使用以下代码在我的应用程序中实现导航栏。(当我使用推送转场时,我的应用程序崩溃了,所以我需要一个模态转场,这意味着在调用模态转场后导航栏被隐藏)UINavigationBar*navbar=[[UINavigationBaralloc]initWithFrame:CGRectMake(0,0,320,50)];//dosomethinglikebackgroundcolor,title,etcyouself[self.viewaddSubview:navbar];有人知道我可以使用上述代码实现导航栏中后退按钮功能的任何方法吗? 最佳答案

iphone - objective-c 中UINavigationBar右侧的UISearchBar

我创建了一个iPad应用程序,我希望在其中将我的searchBar定位在导航栏的右侧。当我在导航栏中添加搜索栏时,它位于导航栏的中间。相反,我想在中间显示特定图像。我怎样才能做到这一点?这是我的代码片段,[self.navigationController.navigationBarsetTintColor:[[UIColoralloc]initWithRed:150.0/255green:22.0/255blue:22.0/255alpha:0.0]];UIImage*image=[UIImageimageNamed:@"logo(1).png"];UIImageView*image

iphone - 暂时隐藏 UINavigationBar 按钮

有没有一种简单的方法可以暂时隐藏UINavigationBar上的按钮? 最佳答案 有很多方法可以用来隐藏UIBarButtonItem。将它设置为nil需要重新实例化,这不是一个令人愉快的路线,所以我选择将它设置为禁用并设置一个空白图像来代替它:self.theButton.enabled=NO;self.theButton.image=[UIImageimageNamed:@"Blank.png"]; 关于iphone-暂时隐藏UINavigationBar按钮,我们在StackOv

ios - 为什么 UINavigationBar 背景图片重复?

图像尺寸为640X44,适用于iPad纵向。由于某种原因,它显示为图案图像而不是拉伸(stretch)图像。iOS6 最佳答案 尝试以下方法来拉伸(stretch)您的图像://loadthebackgroundimagenavbar.pngUIImage*imageNavBar=[UIImageimageNamed:@"navbar"];//settheimageasstretchableandsetintonavbargloballyimageNavBar=[imageNavBarstretchableImageWithLeft

ios - 在 UINavigationBar 上呈现 UISearchController 时推送 View Controller

我已经实现了UISearchController,因此在点击搜索图标时它会出现在UINavigationBar之上。过滤表格后,用户应该能够选择将推送新ViewController的行。问题在于这样做时,搜索Controller仍显示在导航栏上方。我对此进行了研究,建议您将self.definedPresentationContext设置为true。当搜索栏显示在导航栏上方时,这不起作用。当您点击搜索图标时,键盘会出现,但搜索栏不会出现动画。我发现的另一个选项是通过将active设置为false来关闭viewWillDisappear中的搜索Controller。这个解决方案的问题是它