【问题标题】:UIBarButtonItem with image and text, and a border?UIBarButtonItem 带有图像和文本以及边框?
【发布时间】:2012-02-15 22:17:10
【问题描述】:

我想创建一个带有图标和文本的 UIBarButtonItem。我见过this solutionthis one,但是当你设置背景图像时它不会画边框。

我真的不想用我的图标画一个边框(看起来像“普通”样式)。有没有其他办法解决这个问题?

【问题讨论】:

    标签: ios


    【解决方案1】:

    如果您查看链接到的第一个解决方案,您会注意到以下行

    UIBarButtonItem *barButton= [[[UIBarButtonItem alloc] initWithCustomView:chatButton] autorelease];
    

    您可以使用任何您想要的视图来初始化按钮。您可以制作一个按钮,其中包含任何(可接受的)视图。

    例如。

    // GRAPHICAL BUTTON FRAMEWORK
         UIButton* btton = [UIButton buttonWithType:UIButtonTypeCustom];
         [btton setFrame:CGRectMake(0, 0, 30, 30)];
         [btton addTarget:self action:@selector(SOMEROUTINE) forControlEvents:UIControlEventTouchUpInside];
         [btton setImage:[UIImage imageNamed:@"SOME IMAGE"] forState:UIControlStateNormal];
         UIBarButtonItem* remix = [[[UIBarButtonItem alloc] initWithCustomView:btton] autorelease];
    

    希望有帮助!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-28
      • 2011-02-10
      • 1970-01-01
      • 2010-12-04
      • 2016-06-21
      相关资源
      最近更新 更多