How do you set the font size on a UIBarButtonItem?

Objective-C: NSUInteger fontSize = 20; UIFont *font = [UIFont boldSystemFontOfSize:fontSize]; NSDictionary *attributes = @{NSFontAttributeName: font}; UIBarButtonItem *item = [[UIBarButtonItem alloc] init]; [item setTitle:@”Some Text”]; [item setTitleTextAttributes:attributes forState:UIControlStateNormal]; self.navigationItem.rightBarButtonItem = item; Swift: let fontSize:CGFloat = 20; let font:UIFont = UIFont.boldSystemFont(ofSize: fontSize); let attributes:[String : Any] = [NSFontAttributeName: font]; let item = UIBarButtonItem.init(); item.title = “Some Text”; … Read more

UISearchBar cancel button color?

I used some thing like this and worked with me: [[UIBarButtonItem appearanceWhenContainedIn: [UISearchBar class], nil] setTintColor:[UIColor blackColor]]; it changed the cancel button color to black. Update for iOS 9.0, the method appearanceWhenContainedIn is deprecated, use appearanceWhenContainedInInstancesOfClasses instead: [[UIBarButtonItem appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setTintColor:[UIColor blackColor]]; And in Swift 3: UIBarButtonItem.appearance(whenContainedInInstancesOf:[UISearchBar.self]).tintColor = UIColor.black

How can I have a UIBarButtonItem with both image and text?

You can init the UIBarButtonItem with a custom view that has both image and text. Here’s a sample that uses a UIButton. UIImage *chatImage = [UIImage imageNamed:@”08-chat.png”]; UIButton *chatButton = [UIButton buttonWithType:UIButtonTypeCustom]; [chatButton setBackgroundImage:chatImage forState:UIControlStateNormal]; [chatButton setTitle:@”Chat” forState:UIControlStateNormal]; chatButton.frame = (CGRect) { .size.width = 100, .size.height = 30, }; UIBarButtonItem *barButton= [[[UIBarButtonItem alloc] initWithCustomView:chatButton] autorelease]; … Read more

iOS – UIBarButtonItem Identifier – option to create “settings” cogwheel button

Unicode has several notable examples you can simply copy and paste into a string declaration in Xcode, or use the standard Unicode String Escape (\uxxxx) and iOS is actually quite fluent when it comes to Unicode (I know some of the char’s are fairly ugly, but that’s Unicode for ya’): Unicode Character ‘GEAR WITHOUT HUB’ … Read more

Change font of back navigation bar button

To change the appearance of the text in all UIBarButtonItems appearing in all UINavigationBars, do the following in application:didFinishLaunchingWithOptions: [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes: @{UITextAttributeTextColor:[UIColor blackColor], UITextAttributeTextShadowOffset:[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowColor:[UIColor whiteColor], UITextAttributeFont:[UIFont boldSystemFontOfSize:12.0] } forState:UIControlStateNormal]; UPDATE: iOS7 friendly version NSShadow *shadow = [[NSShadow alloc] init]; shadow.shadowOffset = CGSizeMake(0.0, 1.0); shadow.shadowColor = [UIColor whiteColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar … Read more

Changing the Tint Color of UIBarButtonItem

In iOS 7, to set the color of all barButtonItems in your app, set the tintColor property on the application’s window in the AppDelegate. – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { self.window.tintColor = [UIColor whiteColor]; return YES; } More detailed info in Apple’s iOS 7 UI Transition Guide (Specifically under the ‘Using Tint Color` section). ***OR*** … Read more

How do I hide/show the right button in the Navigation Bar

Hide the button by setting the reference to nil, however if you want to restore it later, you’ll need to hang onto a copy of it so you can reassign it. UIBarButtonItem *oldButton = self.navigationItem.rightBarButtonItem; [oldButton retain]; self.navigationItem.rightBarButtonItem = nil; //… later self.navigationItem.rightBarButtonItem = oldButton; [oldButton release]; Personally, in my apps I make my nav … Read more

Xcode 6 Storyboard Unwind Segue with Swift Not Connecting to Exit

This is a known issue with Xcode 6: Unwind segue actions declared in Swift classes are not recognized by Interface Builder In order to get around it you need to: Change class MyViewController to @objc(MyViewController) class MyViewController Create an Objective-C header file with a category for MyViewController that redeclares the segue action. @interface MyViewController (Workaround) … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)