1

如何在不使用 InterfaceBuilder 的情况下将 UISwitch(toggle switch) 添加到 UIToolBar ?它不是系统项目,所以我无法使用

UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemRefresh
                                                                             target:self
                                                                             action:@selector(pressButton1:)];

如何以相同的方式添加拨动开关?
谢谢你。

4

2 回答 2

4

只需将-initWithCustomView:您的开关用作该自定义视图即可。

于 2010-04-27T13:18:22.570 回答
2

这是我在我的 swift 应用程序中所做的,我必须在两种不同的显示模式之间切换。

    let optionSwitch:UISwitch = UISwitch()

    let optionToolButton:UIBarButtonItem = UIBarButtonItem(customView: optionSwitch);
    self.navigationItem.rightBarButtonItem = optionToolButton
于 2016-07-28T06:32:50.527 回答