I want to have a UISwitch in the right corner of a UINavigationItem, instead of a UIBarButton. Is this possible without subclassing the UINavigationItem?
You can create a UIBarButtonItem
with a custom view inside it by using the initWithCustomView:
method. For example:
UISwitch *switch = ...;
UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:mySwitch];
Set this as the left/right item on your UINavigationItem
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With