我想创建一个带有自定义图像的uibarbuttonite,但我不想要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 = [[UIBarButtonItem alloc] initWithCustomView:v];
self.navigationItem.rightBarButtonItem= forward;
[v release];
[image release];
这是可行的,但是如果我必须在10个视图中重复这个过程,这是不干的.
我想我必须细分一下,但是什么呢?
- NSView?
- UIBarButtonItem?
谢谢,
向您致敬,