如何在左侧导航栏中设置带图像或远程图像的标题?

时间:2017-03-21 12:51:53

标签: ios rubymotion-promotion

以下是我的代码和图片可见但不是标题

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

谢谢!

1 个答案:

答案 0 :(得分: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中使用相同的逻辑。