【问题标题】:How to remove/avoid small white splash light on UIBarButtonItem programmatically如何以编程方式删除/避免 UIBarButtonItem 上的小白色飞溅灯
【发布时间】:2011-11-17 16:25:02
【问题描述】:

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

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

【问题讨论】:

  • 您可以执行与答案相同的操作,只需以编程方式执行即可。以编程方式添加按钮并自定义(以编程方式)
  • 我找到了解决方案。我创建了一个 UILabel 对象并将其文本作为我需要的标题。然后我创建了一个 UIBarButtonItem 并使用创建的 UILable 对象为其自定义视图。您可以为该 UILabel 设置任何字体,它会相应地反映。谢谢你们。 :)

标签: iphone ios ipad uibarbuttonitem uitoolbar


【解决方案1】:

要以编程方式做你想做的事,你可以做

    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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-09-10
    • 2023-04-03
    • 1970-01-01
    • 1970-01-01
    • 2015-03-04
    • 1970-01-01
    相关资源
    最近更新 更多