막대 단추 항목 대신 단추를 프로그래밍 방식으로 도구 모음에 추가하고 싶습니다. 단추에 이미지 infodark defaut가 있기 때문에 선택합니다.막대 단추 항목 프로그래밍 방식으로 도구 추가
프로그래밍 방식으로 어떻게 이루어 집니까 ??
막대 단추 항목 대신 단추를 프로그래밍 방식으로 도구 모음에 추가하고 싶습니다. 단추에 이미지 infodark defaut가 있기 때문에 선택합니다.막대 단추 항목 프로그래밍 방식으로 도구 추가
프로그래밍 방식으로 어떻게 이루어 집니까 ??
UIImage* image = [UIImage imageNamed:defaultImage];
CGRect frame = CGRectMake(0, 0, image.size.width, image.size.height);
UIButton* button = [[UIButton alloc] initWithFrame:frame];
[button setTitle:@"Display" forState:UIControlStateNormal & UIControlStateHighlighted];
[button setImage:image forState:UIControlStateNormal];
[button setImage:[UIImage imageNamed:selectedImage] forState:UIControlStateSelected];
[button addTarget:self action:@selector(button_Clicked:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButton = [[UIBarButtonItem alloc] initWithCustomView:button];
멋진 답변 +1에 감사드립니다. – vishiphone
+1 툴바 – Mangesh
에이 모음 단추 추가 도구 모음 바 buttton 항목을 추가하는 – kEvin
UIToolbar
에이 단추를 추가하려면이 코드가 필요합니다. 먼저 그
NSMutableArray *buttons = [[NSMutableArray alloc] initWithCapacity:4];
[buttons addObject: barButtonItem];
[buttons addObject: btnFav];
[buttons addObject: btnGeneralPopOverController];
[buttons addObject: showInfo];
[mytoolbar setItems:buttons animated:NO];
후
UIToolbar
을 초기화 할 수 있습니다 당신은 도구 모음에서보기를 추가하고 다음 볼 수있는 제안 – vishiphone감사를 시도하지 않을 경우 도구 모음에 직접 추가 버튼을 시도 work.first 그 도구 모음 그게 전부에 버튼을 추가 환영합니다 @kEvin – kEvin
에 대한 – vishiphone