Сделать четкий (полупрозрачный) UIBarButttonItem IOS 5 - PullRequest
1 голос
/ 04 февраля 2012

Я пытаюсь установить цвет оттенка для UIBarButtonItem, используя следующий код, но все, что я получаю, это черная кнопка.Есть ли способ сделать это без необходимости использования пользовательских изображений?

[[UIBarButtonItem appearance] SetTintColor:[UIColor clearColor]]:

Ответы [ 2 ]

2 голосов
/ 04 февраля 2012

создать пользовательский элемент UIBarButtonItem с помощью кнопки

UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];

//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0, 0, 24, 24);
button.backgroundColor=[UIColor clearColor];    
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
0 голосов
/ 04 февраля 2012

Если ваша UIToobar или UINavigationBar является полупрозрачной, кнопки панели автоматически становятся полупрозрачными.

[[self.navigationController navigationBar] setTranslucent:YES];

AFAIK, Вы не можете сделать кнопку пуговицы прозрачной.

...