如何以编程方式删除/避免UIBarButtonItem上的小白色闪光灯

时间:2011-11-17 16:25:03

标签: iphone ios ipad uibarbuttonitem uitoolbar

我的问题与问题相同:How to disable the the light that appears when touching a UIBarButtonItem?

如果我们使用Interface builder,我已经阅读了答案。如果以编程方式添加工具栏怎么办?如何避免条形按钮项上的指示灯?

1 个答案:

答案 0 :(得分:0)

以编程方式执行您想要的操作

    UIBarButtonItem *item;
    UIButton *b2=[[UIButton alloc] initWithFrame:frame];
    [b2 addTarget:self action:@selector(settings:) forControlEvents:UIControlEventTouchUpInside];
   //you can set the background image or whatnot
    [b2 setBackgroundImage:[UIImage imageNamed:@"settings.png"] forState:UIControlStateNormal]; 
    item=[[UIBarButtonItem alloc] initWithCustomView:b2];
      //then set the button on the UIToolbar through the items property