
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ViewController : UIViewController { | |
override func viewDidLoad() { | |
super.viewDidLoad() | |
self.navigationItem.title = "title영역" | |
let my_switch = UISwitch(frame: .zero) | |
my_switch.isOn = true // | |
my_switch.addTarget(self, action: #selector(switchToggled(_:)), for: .valueChanged) | |
let switch_display = UIBarButtonItem(customView: my_switch) | |
let a = UIBarButtonItem(title: "Add", style: .plain, target: self, action: #selector(addTapped)) | |
let b = switch_display | |
a.tintColor = UIColor.red | |
navigationItem.rightBarButtonItems = [b, a] | |
} | |
@IBAction func addTapped(_ sender: UISwitch) { | |
print("addTapped") | |
} | |
@IBAction func switchToggled(_ sender: UISwitch) { | |
if sender.isOn { | |
print( "The switch is now true!" ) | |
} else { | |
print( "The switch is now false!" ) | |
} | |
} | |
} |
devxoul/UINavigationItem-Margin
Margins for UINavigationItem. Contribute to devxoul/UINavigationItem-Margin development by creating an account on GitHub.
github.com
'IOS(Swift)' 카테고리의 다른 글
Swift ScrollView (0) | 2021.03.10 |
---|---|
IOS Collectionview Image slider (0) | 2021.03.09 |
IOS navigationItem (0) | 2021.02.28 |
IOS navigationItem title (0) | 2021.02.28 |
Swift loading bar (0) | 2021.02.16 |