_嵌入式开发_

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
UIButton *playNowButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 64, 32)];
[playNowButton setBackgroundImage:[UIImage imageNamed:@"imagename.png"] forState:UIControlStateNormal];
[playNowButton addTarget:self action:@selector(doSomething)forControlEvents:UIControlEventTouchDown];
UIBarButtonItem *bar =[[UIBarButtonItem alloc] initWithCustomView:playNowButton];
[playNowButton release];

思路 创建一个UIButton将创建的UIButton作为UIBarButtonItem的参数传给UIBarButtonItem的初始化消息initWithCustomView中。

参考:http://mkhgg.blog.51cto.com/1741572/616479

http://stackoverflow.com/questions/2681321/uibarbuttonitem-with-custom-image-and-no-border

 

 

posted on 2013-08-17 21:04  _嵌入式开发_  阅读(212)  评论(0编辑  收藏  举报