IOS custom control panel. Is the element width always set to 44?
I created two custom UIBarButtonItems from the UI constructor and assigned them a width of 20.
However, the result of the UIBarButtonItem has a fixed width of 44. As shown in this screenshot:
Is there a way to reduce the width of these UIBarButtonItems?
+3
DavidLiu
source
to share
2 answers
You can run any UIView class as UIBarButtonItem Here is a UIButton ...
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:[UIImage imageNamed:@"my_bar_button.png"] forState:UIControlStateNormal];
[button sizeToFit];
[button addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];
return [[UIBarButtonItem alloc] initWithCustomView:button];
This button will match the size of my_bar_button.png ... can be any size ..
+3
Magoo
source
to share
add uibuttonin uibarbuttonitem and adjust its width / height as needed
0
ZAZ
source
to share