如何以编程方式移除/避免UIBarButtonItem上的小白色溅射光



我的问题是一样的问题:如何禁用触摸UIBarButtonItem时出现的灯?

如果我们使用接口构建器,我已经阅读了答案。如果我以编程方式添加工具栏呢?我如何避免栏按钮项上的光?

如果您想要通过编程实现,可以执行以下命令

    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

最新更新