使用Xcode界面构建器,我可以将UIBarButton图像图标更改为内置标识符,例如搜索图标或相机图标,如下所示:
但是,我没有看到任何可以编辑常规UIButton的标识符的地方。只需点击一下UIBarButton就不可能做到这一点吗?
答案 0 :(得分:4)
但是,您可以通过编程方式执行以下操作:
UIButton *cameraButton = [[UIButton alloc] init];
cameraButton.imageView.image = [UIImage imageNamed:@"camera"];
UIBarButtonItem *camera = [[UIBarButtonItem alloc]initWithCustomView:cameraButton];
[camera setAction:@selector(doSomething)];
[camera setTarget:self];
使用您想要的相机图像创建UIButton。然后使用视图创建自定义UIBarButtonItem。 不幸的是,倒数并不那么简单。
希望这有帮助!