码迷,mamicode.com
首页 > 其他好文 > 详细

为UIButtonBarItem创建分类

时间:2014-12-11 01:30:20      阅读:261      评论:0      收藏:0      [点我收藏+]

标签:io   ar   sp   for   on   bs   cti   ad   tt   

 

#import "UIBarButtonItem+Extension.h"

 

@implementation UIBarButtonItem (Extension)

+(UIBarButtonItem *)itemWithImageName:(NSString *)ImageName highImageName:(NSString *)highImageName target:(id)target action:(SEL)action{

 

    UIButton *btn=[[UIButton alloc] init];

          [btn setBackgroundImage:[UIImage imageNamed:ImageName] forState:UIControlStateNormal];

          [btn setBackgroundImage:[UIImage imageNamed:highImageName] forState:UIControlStateHighlighted];

    

    btn.frame=CGRectMake(0, 0, btn.currentBackgroundImage.size.width, btn.currentBackgroundImage.size.height);

    

    [btn addTarget:target action:action forControlEvents:UIControlEventTouchUpInside];

    

          return [[UIBarButtonItem alloc]initWithCustomView:btn];

 

}

@end

 

为UIButtonBarItem创建分类

标签:io   ar   sp   for   on   bs   cti   ad   tt   

原文地址:http://www.cnblogs.com/zhibin/p/4156656.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!