How to remove/avoid small white splash light on UI

2019-08-28 15:08发布

My issue is same as question: How to disable the the light that appears when touching a UIBarButtonItem?

I have read answer if we use Interface builder. What if I add toolbar programmatically? How can I avoid the light on the bar button item?

1条回答
成全新的幸福
2楼-- · 2019-08-28 16:06

To do what you want programatically you can do

    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
查看更多
登录 后发表回答