2017-12-25 15 views

답변

1

버튼 사이에 2 개의 flexibleSpace를 추가하기 만하면됩니다. 예를 들어

:

let toolbar = UIToolbar(frame: CGRect(x: 0, y: UIApplication.shared.statusBarFrame.height, width: view.bounds.width, height: 44)) 

var items = [UIBarButtonItem]() 

items.append(UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)) 
items.append(UIBarButtonItem(barButtonSystemItem: .add, target: self, action: #selector(test))) 
items.append(UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)) 

toolbar.items = items 
self.view.addSubview(toolbar) 
관련 문제