Change the font size and font style of UISearchBar iOS 7

后端 未结 9 849
借酒劲吻你
借酒劲吻你 2020-12-13 03:17

How can I change the font size and font style of UISearchBar in iOS 7?

UITextField *textField = [[searchBar subviews] objectAtIndex:1];
[textField setFont:[U         


        
9条回答
  •  猫巷女王i
    2020-12-13 03:47

    For Swift 4 you need to reference the NSAttributedStringKey enum:

    UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self])
            .defaultTextAttributes = [NSAttributedStringKey.font.rawValue: UIFont(...)]
    

提交回复
热议问题