0
我有一個uibarbuttonitem,但我使用initwithcustomview初始化它。我想用圖像改變它的背景,但我不知道該怎麼做。我用的setBackground方法,這樣使用圖像更改uibarbuttonitem背景
NSArray *segmentText = [segmentTextMutable copy];
UIImage *image = [[[UIImage alloc] init] autorelease];
image = [UIImage imageNamed:@"bunga.jpg"];
_docSegmentedControl = [[UISegmentedControl alloc] initWithItems:segmentText];
_docSegmentedControl.autoresizingMask = UIViewAutoresizingFlexibleHeight;
_docSegmentedControl.segmentedControlStyle = UISegmentedControlStyleBezeled;
[_docSegmentedControl addTarget:self action:@selector(docSegmentAction:) forControlEvents:UIControlEventValueChanged];
[_docSegmentedControl setBackgroundColor:[UIColor colorWithPatternImage:image]];
但仍的UIBarButtonItem不顯示圖像,它只是改變了分段控制的背景下,而不是barbutton。 有人能幫助我嗎?
我可以用圖像填充tintColor嗎? – 2010-11-29 09:21:04