override func viewDidLoad() {
super.viewDidLoad()
let photoItem = UIBarButtonItem(title: "Photo Library", style: .done, target: self, action: #selector(ViewController.showImagePickerForPhotoPicker(_:)))
photoItem.tintColor = UIColor.white
let spaceItem = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: nil, action: nil)
let cameraItem = UIBarButtonItem(barButtonSystemItem: .camera, target: self, action: #selector(showImagePickerForCamera(_:)))
cameraItem.tintColor = UIColor.white
let toolBar = UIToolbar(frame: CGRect.init(x: 0, y: view.frame.size.height-50, width: view.frame.size.width, height: 50))
toolBar.barTintColor = UIColor.darkGray//背景色
toolBar.items = [photoItem, spaceItem, cameraItem]
view.addSubview(toolBar)
}
@objc func showImagePickerForPhotoPicker(_ sender : UIBarButtonItem){
}
@objc func showImagePickerForCamera(_ sender: UIBarButtonItem) {
}
网友评论