Anna88
Anna88

Reputation: 355

How can i set a title with image or remote image in left nav bar?

Below is my code and image is visible but not the title

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

Thanks!

Upvotes: 0

Views: 25

Answers (1)

Bharath Vankireddy
Bharath Vankireddy

Reputation: 932

iOS provides a option to add your custom view to UINavigationBarButtonItem. Code looks like as follows in 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];

Use the same logic in swift.

Upvotes: 0

Related Questions