2014-04-11 1 views
0

7 이상의 사용자 정의 왼쪽 막대 버튼 항목에 문제가 있습니다. 여기서 버튼 프레임 (x pos = -10)을 움직일 수 있습니다. 하지만 왼쪽 바 버튼 x pos는 바꿀 수 없었습니다. 여기ios 7의 사용자 정의 leftBarButtonItem 문제

내 코드 :

BackButton *backButton = [[BackButton alloc] initWithFrame:CGRectMake(0, 0, 60, 44) viewFrom:self]; 
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc] initWithCustomView:backButton]; 
self.navigationItem.leftBarButtonItem = customBarItem; 

self.navigationItem.leftBarButtonItem.customView.backgroundColor = [UIColor yellowColor]; 

아이폰 OS 7.1에서 : enter image description here

enter image description here

아이폰 OS 6.1에서 친절 사람이 보관하는 데 도움이. 미리 감사드립니다 ...

답변

2

하나의 솔루션은 UIButton을 만들고 navigationBar 서브 뷰에 추가합니다. 예 :

UIButton *backButton = [UIButton alloc] initWithFrame:CGRectMake:(0,0,60,44)]; 
backButton.backgroundColor = [UIColor yellowColor]; 
[self.navigationController.navigationBar addSubview:backButton]; 

희망이 있습니다.

+0

감사합니다 .. 잘 작동합니다 ... –

1
UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 60.0f, 44.0f)]; 
UIButton *backButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[backButton setBackgroundColor:[UIColor yellowColor]]; 
backButton.frame = CGRectMake(-20, 0.0f, 60.0f, 44.0f); 
[backView addSubview:backButton]; 
UIBarButtonItem *customBarItem = [[UIBarButtonItem alloc]initWithCustomView:backView]; 
self.navigationItem.leftBarButtonItem = customBarItem; 
+0

저에게 잘 부탁드립니다. –