0

下面是我的代码和图像是可见的,但不是标题

class PromotionScreen < PM::GroupedTableScreen
  title 'User screen'
  include ProfileImageHelpers

    def on_load
        set_nav_bar_button :left, {
                      title: 'Dev', 
                      image: user_profile_image(Auth.current_user),
                      action: :nil 
                     }

    end
end

谢谢!

4

1 回答 1

0

iOS 提供了一个选项来将您的自定义视图添加到UINavigationBarButtonItem. Objective-C 中的代码如下所示。

 UIButton * btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn setBackgroundImage:[UIImage imageNamed:@""] forState:UIControlStateNormal];
[btn addTarget:self action:@selector(btnTapped:) forControlEvents:UIControlEventTouchUpInside];
self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:btn];

在 swift 中使用相同的逻辑。

于 2017-03-21T12:58:34.603 回答