简体   繁体   中英

Add image to toolbar in swift?

My question is similar to this but I just wanted to know how to do it in swift. I want to add a UIImageView to a toolbar.

let toolBar = UIToolbar()
let button = UIBarButtonItem(image: UIImage(named: "imageName"), style: .plain, target: self, action: #selector(buttonAction(_:)))
toolBar.items = [button]

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