I'm creating a stopwatch in Swift and I want to change the play icon I have selected for a bar button to a pause icon when the button is pressed to start the stopwatch. How do you do this?
相关问题
- 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
- SwiftUI: UIImage (QRCode) does not load after call
相关文章
- 现在使用swift开发ios应用好还是swift?
- UITableView dragging distance with UIRefreshContro
- Using if let syntax in switch statement
- TCC __TCCAccessRequest_block_invoke
- Where does a host app handle NSExtensionContext#co
- Enum with associated value conforming to CaseItera
- Swift - hide pickerView after value selected
- Is there a Github markdown language identifier for
I believe that you already found a solution for your question, but I'll leave this in case anyone still needs it.
UIBarButtonItem
is not aUIControl
, however you can initialise it with a custom view, i.e. a customUIButton
programmatically as follows:idea from Custom "Pressed" UIBarButtonItem Backgrounds
You can not change a
UIBarButtonItem
's style during runtime. You must remove theUIBarButtonItem
and then add theUIBarButtonItem
you'd like.UIBarButtonItem Class Reference
For Swift 3
This is how I did it in Swift 3:
For Swift 4
var favoritesBarButtonOn: UIBarButtonItem! var favoritesBarButtonOFF: UIBarButtonItem!