简体   繁体   中英

Using a system icon in a UIButton, in a UIToolbar?

I am trying to have a button, in a toolbar, use a system icon, by modifying its appearance in the XCode 7 interface builder. If I do this at the toolbar item level, then this just becomes a regular UIButtonBarItem, removing the button underneath. This means it won't send any press items, from what I can see.

I don't see a way on the UIButton, in the interface builder, to specify a system icon. Ideally I would like to avoid having to do this programmatically. Can anyone suggested a way?

Note, Apple indicates :

iOS provides a lot of small icons—representing common tasks and types of content—for use in tab bars, toolbars, navigation bars, and Home screen quick actions. It's a good idea to use the built-in icons as much as possible because users already know what they mean.

Unfortunately it is not clear how to leverage them? Some sources indicate using "iOS-Artwork-Extractor", but I would hope there is another way to address this, maybe via some API call?

XCode 7.2.1, targeting iOS.

For the UIButtonBarItem and the subset of icons available there (see table 41-1 in the iOS Human Interface Guidelines ), to have it notify the code that it was pressed, then it is simply a question of adding an 'IBAction' function to the class corresponding to the view, for example (Swift):

@IBAction func flashItemActioned (sender: UIButton) {
   //
}

and then linking the "sent actions" of the item with the function in the first responder.

For UIButton based implementations I haven't found a solution beyond the "iOS-Artwork-Extractor".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM