具有自定义图像且没有边框的UIBarButtonItem
我想用自定义图像创建UIBarButtonItem,但是我不希望iPhone添加边框,因为我的图像有特殊边框。 它与后退按钮相同,但前进按钮相同。 这个程序是针对内部项目的,所以我不在乎苹果是否拒绝或批准它或喜欢它:-) 如果我使用UIBarButtonItem的initWithCustomView:v属性,则可以执行以下操作: UIImage *image = [UIImage imageNamed:@"right.png"]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setBackgroundImage: [image stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState:UIControlStateNormal]; [button setBackgroundImage: [[UIImage imageNamed: @"right_clicked.png"] stretchableImageWithLeftCapWidth:7.0 topCapHeight:0.0] forState:UIControlStateHighlighted]; button.frame= CGRectMake(0.0, 0.0, image.size.width, image.size.height); [button addTarget:self action:@selector(AcceptData) forControlEvents:UIControlEventTouchUpInside]; UIView *v=[[UIView alloc] initWithFrame:CGRectMake(0.0, 0.0, image.size.width, image.size.height) ]; [v addSubview:button]; UIBarButtonItem *forward = …