我想要一个可伸缩的后退按钮我现在正在使用这行编码,这给了我一个后退按钮,但我希望它可以伸缩,其中包含自定义标题所以我尝试在代码中添加这一行
[button setTitle:@"back" forState:UIControlStateNormal];
但它没有用
UIImage *buttonImage = [[UIImage imageNamed:@"backButton.png"] resizableImageWithCapInsets:UIEdgeInsetsMake(0, 16, 0, 16)];
//create the button and assign the image
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setImage:buttonImage forState:UIControlStateNormal];
//buttonImage.size.width
//set the frame of the button to the size of the image (see note below)
button.frame = CGRectMake(0, 0, buttonImage.size.width, buttonImage.size.height);
[button addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
//create a UIBarButtonItem with the button as a custom view
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:button];
self.navigationItem.leftBarButtonItem = customBarItem;
在它显示的 NavigationBar 中,我需要一个标题以便它可以拉伸?