我应该如何在导航栏上绘制自定义按钮

Nau*_*tak 2 iphone objective-c uinavigationbar

我想在导航栏上绘制自定义按钮.

有谁能够帮我.

Krz*_*cki 5

简单

[[UIBarButtonItem alloc] initWithCustomView: customButton];
Run Code Online (Sandbox Code Playgroud)

将工作

所以类似的东西:

UIButton *button = [UIButton buttonWithType: UIButtonTypeCustom];
[button setImage:[UIImage imageNamed:@"animage.png"]];
[button addTarget:self action:@selector(onClick:) forControlEvents: UIControlEventTouchUpInside];
UIBarButtonItem *customItem = [[UIBarButtonItem alloc] initWithCustomView: button];
[self.navigationItem setLeftBarButtonItem:customItem];
Run Code Online (Sandbox Code Playgroud)

干杯,KrzysztofZabłocki