我需要自定义 UIBarButtonItem 后退按钮,使其显示为一个简单的箭头图标(如 Facebook、Twitter 等)。我是否需要创建一个自定义 UIBarButtonItem 并将其手动添加到导航栏,或者有没有办法通过外观 API 来做到这一点?
谢谢
Best Answer-推荐答案 strong>
你必须自己制作并添加它
您可以这样做(这是用于使用图像的自定义按钮)
UIImage* image3 = [UIImage imageNamed"favorites.png"];
CGRect frameimg = CGRectMake(0, 0, image3.size.width, image3.size.height);
UIButton *someButton2 = [[UIButton alloc] initWithFrame:frameimg];
[someButton2 setBackgroundImage:image3 forState:UIControlStateNormal];
[someButton2 addTarget:self actionselector(loadFavorites)
forControlEvents:UIControlEventTouchUpInside];
[someButton2 setShowsTouchWhenHighlighted:YES];
UIBarButtonItem *favoritesButton =[[UIBarButtonItem alloc] initWithCustomView:someButton2];
self.navigationItem.rightBarButtonItems =[NSArray arrayWithObjects:favoritesButton, nil];
关于ios - 自定义 UIBarButtonItem 后退按钮,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/16138280/
|