UIToolbar에서 사용해야하는 UIBarButtonItem에 이미지를 추가하려고합니다.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];
귀하의 도움을 많이 주시면 감사하겠습니다.
감사합니다! 일반적 UIKit 물건에 기대하는 것보다
당신에게 MVDS 감사! 예, 프레임이었습니다 !! 단순히이 줄을 추가했습니다. button2.frame = CGRectMake (0, 0, image.size.width, image.size.height); 나는이 일을하기 위해 막 정신을 잃었습니다. 나는 이제까지 Button-Frame 관계를 잊을 것이라고 생각하지 않는다 !! 다시 한번 감사드립니다. –