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

How do you change the color of a UIFont?

UIFont does not contain/maintain any color information, so this is not possible. In general, controls that use UIFont such as a UILabel have both a font and a textColor property. So you would set a label’s font and it’s color like this: myLabel.textColor = [UIColor blackColor]; myLabel.font = [UIFont fontWithName:@”Helvetica-Bold” size:8.0];

Convert from SwiftUI.Font to UIFont

A bit of a hack but works (doing the other direction is left as an exercise to the reader). extension UIFont { class func preferredFont(from font: Font) -> UIFont { let uiFont: UIFont switch font { case .largeTitle: uiFont = UIFont.preferredFont(forTextStyle: .largeTitle) case .title: uiFont = UIFont.preferredFont(forTextStyle: .title1) case .title2: uiFont = UIFont.preferredFont(forTextStyle: .title2) case … Read more

Custom UIFont baseline shifted

Here or even here you can find the solutions for you. It’s all about baseline. Note There’s a problem with installing Apple Fonts Utility on El Capitan. See https://apple.stackexchange.com/questions/211138/apple-font-tools-cannot-install-in-macbook-pro-el-capitan for a workaround. To edit these in the font you will need to download the Apple Font Tool Suite. Once you’ve installed this you need to … 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

Change the font size of UISearchBar

I suggest yet a different option for iOS 5.0 and up: [[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setFont:[UIFont systemFontOfSize:14]]; for iOS 8 (as linked by Mike Gledhill): [[UITextField appearanceWhenContainedIn:[UISearchBar class], nil] setDefaultTextAttributes:@{ NSFontAttributeName: [UIFont fontWithName:@”Helvetica” size:20], }]; for iOS 9 and above: [[UITextField appearanceWhenContainedInInstancesOfClasses:@[[UISearchBar class]]] setDefaultTextAttributes:@{NSFontAttributeName: [UIFont fontWithName:@”Helvetica” size:20]}]; This way you don’t need to mess with … Read more

How do you stylize a font in Swift?

I am assuming this is a custom font. For any custom font this is what you do. First download and add your font files to your project in Xcode (The files should appear as well in “Target -> Build Phases -> Copy Bundle Resources”). In your Info.plist file add the key “Fonts provided by application” … Read more

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