uibarbuttonitem

UISearchBar cancel button color?

流过昼夜 提交于 2019-11-28 18:36:37
When I drop a UISearchBar into my view inside Interface Builder, and change its style to Black Opaque, the cancel button stays unfittingly blue / gray and doesn't become black. How can I make the cancel button black? EDIT: It does work like this: // Assume a UISearchBar searchBar. NSArray *subviews = [searchBar subviews]; // The index depends on how you configure the searchBar. UIButton *cancelButton = [subviews objectAtIndex:3]; // Set the style to "normal" style. [cancelButton setStyle:0]; But the setStyle: method is from a private framework, so this might be an issue when submitting the app

Change the height of NavigationBar and UIBarButtonItem elements inside it in Cocoa Touch

不想你离开。 提交于 2019-11-28 17:21:45
问题 I suppose it's not strictly in line with Apple guidelines but I guess it must be possible somehow. I'd like to change the height of navigation bar inside UINavigationController and the height of UIBarButtonItem elements inside that bar. Using a trick from this question I managed to change the height of navigation bar but I can see no way of adjusting the height of bar button items. If anyone knows how to change the size of bar button items, please help me out. 回答1: Maybe this tutorial about a

How to set the action for a UIBarButtonItem in Swift

拜拜、爱过 提交于 2019-11-28 17:08:28
How can the action for a custom UIBarButtonItem in Swift be set? The following code successfully places the button in the navigation bar: var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:nil) self.navigationItem.rightBarButtonItem = b Now, I would like to call func sayHello() { println("Hello") } when the button is touched. My efforts so far: var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self, action:sayHello:) // also with `sayHello` `sayHello()`, and `sayHello():` and.. var b = UIBarButtonItem(title: "Continue", style: .Plain, target: self,

Multiple UIBarButtonItems in UINavigationBar

柔情痞子 提交于 2019-11-28 16:43:46
How to Create multiple bar button in navigation bar? You must use UIToolbar and set the toolbar with buttons: // create a toolbar where we can place some buttons UIToolbar *toolbar = [[UIToolbar alloc] initWithFrame:CGRectMake(0, 0, 100, 45)]; [toolbar setBarStyle: UIBarStyleBlackOpaque]; // create an array for the buttons NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:3]; // create a standard save button UIBarButtonItem *saveButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(saveAction:)]; saveButton.style =

How to remove all navigationbar back button title

瘦欲@ 提交于 2019-11-28 16:17:58
When I push a UIViewController , it has some title in back button at new UIViewController , if the title has a lot of text, It does not look good in iPhone 4s So I want to remove it. If I add some code in prepareForSegue function, it is going to be a trouble. Any better way to achieve this? If you want back arrow so following code put into AppDelegate file into didFinishLaunchingWithOptions method. For Objective-C [[UIBarButtonItem appearance] setBackButtonTitlePositionAdjustment:UIOffsetMake(0, -60) forBarMetrics:UIBarMetricsDefault]; For Swift let BarButtonItemAppearance = UIBarButtonItem

How to create fixed space and flexible space bar button items programmatically?

荒凉一梦 提交于 2019-11-28 16:06:01
问题 I want to create UIBarButtonItems programmatically and place these fixed space items between buttons. 回答1: UIBarButtonItem *fixedItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFixedSpace target:nil action:nil]; fixedItem.width = 20.0f; // or whatever you want UIBarButtonItem *flexibleItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil]; 回答2: Swift // Fixed Space let fixedSpace: UIBarButtonItem =

UIBarButtonItem with custom image and no border

不羁岁月 提交于 2019-11-28 15:24:29
I want to create a UIBarButtonItem with a custom image, but I don't want the border that iPhone adds, as my Image has a special border. It's the same as the back button but a forward button. This App is for an inHouse project, so I don't care if Apple reject or approves it or likes it :-) If I use the initWithCustomView:v property of the UIBarButtonItem, I can do it: UIImage *image = [UIImage imageNamed:@"right.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage: [image stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState

Change UIBarButtonItem from UISearchBar

馋奶兔 提交于 2019-11-28 14:11:39
I'd like to change the text font and color of the Cancel button inside the UISearchBar in iOS 8. I've tried the solutions for iOS 6 and 7 already and they don't seem to work. This was not the solution I was looking for, but it worked. let cancelButtonAttributes: NSDictionary = [NSFontAttributeName: FONT_REGULAR_16!, NSForegroundColorAttributeName: COLOR_BLUE] UIBarButtonItem.appearance().setTitleTextAttributes(cancelButtonAttributes, forState: UIControlState.Normal) What you are looking for is: //The tintColor below will change the colour of the cancel button searchBar.tintColor = UIColor

iOS开发UINavigation系列二——UINavigationItem

送分小仙女□ 提交于 2019-11-28 12:38:33
iOS开发UINavigation系列二——UINavigationItem 一、引言 UINavigationItem是导航栏上用于管理导航项的类,在上一篇博客中,我们知道导航栏是通过push与pop的堆栈操作来对item进行管理的,同样,每一个Item自身也有许多属性可供我们进行自定制。这篇博客,主要讨论UINavigationItem的使用方法。 UINavigationBar: http://my.oschina.net/u/2340880/blog/527706 。 二、来说说UINavigationItem Item,从英文上来理解,它可以解释为一个项目,因此,item不是一个简单的label标题,也不是一个简单的button按钮,它是导航栏中管理的一个项目的抽象。说起来有些难于理解,通过代码,我们就能很好的理解Item的意义。 首先,我们创建一个item,用UINavigationBar导航栏push出来: UINavigationItem * item = [[UINavigationItem alloc]initWithTitle:@"title"]; UINavigationBar * bar = [[UINavigationBar alloc]initWithFrame:CGRectMake(0, 0, 320, 64)]; [bar

Make a UIBarButtonItem disappear using swift IOS

生来就可爱ヽ(ⅴ<●) 提交于 2019-11-28 11:52:38
I have an IBOutlet that I have linked to from the storyboard @IBOutlet var creeLigueBouton: UIBarButtonItem! and I want to make it disappear if a condition is true if(condition == true) { // Make it disappear } Do you really want to hide/show creeLigueBouton ? It is instead much easier to enable/disable your UIBarButtonItems. You would do this with a few lines: if(condition == true) { creeLigueBouton.enabled = false } else { creeLigueBouton.enabled = true } This code can even be rewritten in a shorter way: creeLigueBouton.enabled = !creeLigueBouton.enabled Let's see it in a UIViewController