UIToolbar で使用する必要がある UIBarButtonItem に画像を追加しようとしています。
画像を読み取ってUIImageViewで表示することさえできましたが、それをUIBarButtonItemに追加してからそのアイテムをUIToolbarに追加すると、ツールバーは「空白の白い」スペースをサイズと形状に置き換えます読み込もうとしている画像。
ここに私がしようとしているものがあります。
UIImage *image = [UIImage imageNamed:@"6.png"];
//This is the UIImageView that I was using to display the image so that i know that it is being read from the path specified.
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
imageView.frame = CGRectMake(0, 50, image.size.width, image.size.height);
[self.view addSubview:imageView];
UIButton *button1 = [UIButton buttonWithType:UIButtonTypeCustom];
[button1 setImage:image forState:UIControlStateNormal];
//This is the first way that I was trying to accomplish the task but i just get a blank white space
//This is the Second way but with the same blank white result.
UIBarButtonItem *systemItem1 = [[UIBarButtonItem alloc] initWithCustomView:button2];
NSArray *items = [NSArray arrayWithObjects: systemItem1, nil];
//Adding array of buttons to toolbar
[toolBar setItems:items animated:NO];
//Adding the Toolbar to the view.
[self.view addSubview:toolBar];
あなたの助けは大歓迎です。
ありがとう!
シュマイス・ウル・ハク