我正在使用主详细信息模板开发应用程序。这里我默认有“编辑”和“添加”按钮。任何人都可以指导我如何将默认编辑按钮更改为带有边框图像的编辑按钮,如whatsapp和oblige中的那样。
答案 0 :(得分:1)
使用此代码:
UIImage* image_bk = [UIImage imageNamed:@"whatsAPP_image.png"];
CGRect frameimg = CGRectMake(0, 0, image_bk.size.width, image_bk.size.height);
UIButton *someButton = [[UIButton alloc] initWithFrame:frameimg];
[someButton setBackgroundImage:image_bk forState:UIControlStateNormal];
[someButton addTarget:self action:@selector(editAction)
forControlEvents:UIControlEventTouchUpInside];
[someButton setShowsTouchWhenHighlighted:YES];
UIBarButtonItem *customEditButton =[[UIBarButtonItem alloc] initWithCustomView:someButton];
self.navigationItem.leftBarButtonItem=customEditButton;