I have a UIBarButtonItem
in my UIToolbar
titled Done. Now I want to change the font from the default to "Trebuchet MS" with Bold. How can I do that?
相关问题
- Core Data lightweight migration crashes after App
- How can I implement password recovery in an iPhone
- State preservation and restoration strategies with
- “Zero out” sensitive String data in Swift
- Get the NSRange for the visible text after scroll
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Xcode: Is there a way to change line spacing (UI L
- Swift - hide pickerView after value selected
- How do you detect key up / key down events from a
- didBeginContact:(SKPhysicsContact *)contact not in
To be precise, this can be done as below
Or with object literal syntax:
For convenience, here's the Swift implementation:
These are great answers above. Just updating for iOS7:
In Swift 4, you can change the font and colour of
UIBarButtonItem
by adding the following code.Assuming you want to support iOS4 and earlier, your best bet is to create a bar button using the
initWithCustomView:
method and supply your own view which could be something like a UIButton where you can easily customise the font.You can also drag a UIButton onto a toolbar or navigation bar in Interface Builder if you want to create the button with drag-and-drop instead of programmatically.
Unfortunately this means creating the button background image yourself. There's no way to customise the font of a standard UIBarButtonItem prior to iOS5.
In Swift you would do this as followed:
UIBarButton
haven't property related to change the font. But you can create a button with custom font and then add into UIBarButton. It May be solved your problem