开发者

create background image of toolbar button

I am new in iphone...i have created toolbar with Four buttons...code is show below...I want to add开发者_如何学Python background image for each button. Anybody help me to create this..

TransparentToolbar* toolbar = [[TransparentToolbar alloc] initWithFrame:CGRectMake(0, 0, 256, 50)];
[toolbar setBarStyle: UIBarStyleBlackTranslucent];//UIBarStyleBlackTranslucent
toolbar.translucent = YES;

NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:4];  
UIBarButtonItem *Messages = [[UIBarButtonItem alloc] initWithTitle:@"About Me" style:UIBarButtonItemStyleBordered target:self action:@selector(currentuserdetails:)];
[buttons addObject:Messages];
[Messages release];



UIBarButtonItem *sendMessageBtn = [[UIBarButtonItem alloc] initWithTitle:@"Send Message" style:UIBarButtonItemStyleBordered target:self action:@selector(sendMessage)]; 
[buttons addObject:sendMessageBtn];
[sendMessageBtn release];


UIBarButtonItem *blockBtn = [[UIBarButtonItem alloc] initWithTitle:@"Block" style:UIBarButtonItemStyleBordered target:self action:@selector(blockcurrentuser:)];    
[buttons addObject:blockBtn];
[blockBtn release];

[toolbar setItems:buttons animated:NO];

// place the toolbar into the navigation bar
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
                                         initWithCustomView:toolbar];
[toolbar release];





TransparentToolbar* toolbar = [[TransparentToolbar alloc] initWithFrame:CGRectMake(0, 0, 256, 50)];
[toolbar setBarStyle: UIBarStyleBlackTranslucent];//UIBarStyleBlackTranslucent
toolbar.translucent = YES;

NSMutableArray* buttons = [[NSMutableArray alloc] initWithCapacity:4];  
UIBarButtonItem *Messages = [[UIBarButtonItem alloc] initWithTitle:@"About Me" style:UIBarButtonItemStyleBordered target:self action:@selector(currentuserdetails:)];
[buttons addObject:Messages];
[Messages release];



UIBarButtonItem *sendMessageBtn = [[UIBarButtonItem alloc] initWithTitle:@"Send Message" style:UIBarButtonItemStyleBordered target:self action:@selector(sendMessage)]; 
[buttons addObject:sendMessageBtn];
[sendMessageBtn release];


UIBarButtonItem *blockBtn = [[UIBarButtonItem alloc] initWithTitle:@"Block" style:UIBarButtonItemStyleBordered target:self action:@selector(blockcurrentuser:)];    
[buttons addObject:blockBtn];
[blockBtn release];

[toolbar setItems:buttons animated:NO];

// place the toolbar into the navigation bar
self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]
                                         initWithCustomView:toolbar];
[toolbar release];


        UIImage *image = [UIImage imageNamed:@"audio-off.png"];
        UIButton *myMuteButton = [UIButton buttonWithType:UIButtonTypeCustom];
        myMuteButton.bounds = CGRectMake( 0, 0, image.size.width, image.size.height );    
        [myMuteButton setImage:image forState:UIControlStateNormal];
        [myMuteButton addTarget:self action:@selector(mute) forControlEvents:UIControlEventTouchUpInside];    
        UIBarButtonItem *myMuteBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:myMuteButton];   

        [buttons addObject:myMuteBarButtonItem];



        [myMuteBarButtonItem release];
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜