How to remove/avoid small white splash light on UIBarButtonItem programmatically

丶灬走出姿态 提交于 2019-12-11 15:34:18

问题


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:


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


来源:https://stackoverflow.com/questions/8170641/how-to-remove-avoid-small-white-splash-light-on-uibarbuttonitem-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!