Views 2083 Votes 0 Comment 0
Atachment
Attachment '3'
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
구글에 비슷한 질문을 했더니 역시나 Stackoverflow에 누군가 같은 질문을 ㅋㅋ

Stackoverflow 질문 내용
Can I change horizontal position of UINavigationBar's title?
Like this image (MY ACCOUNT is the UINavigationBar title)
question.png



Stackoverflow 답변 내용
Change the position of the navigationbar title will be difficult.
In my experience, I could use either one of below two ways;

1. Set left button. When you set title and image both to UIButton, it will be exactly same look as like as you want. And set that button to the left button of navigationItem.

2. You can create new view which contains UILabel which have that position and set that view to navigationItem's titleView


위에서 설명한 내용을 작성한 코드

# 1번 내용 코드과 실행 내용
NSMutableArray *leftButtons = [[NSMutableArray alloc] init];
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setFrame:CGRectMake(2, 2, 40, 40)];
[button setBackgroundImage:[UIImage imageNamed:@"title_btn_back_w_nor"]
                  forState:UIControlStateNormal]; // SET the image name for your wishes
[button addTarget:self action:@selector(backButtonTapped)
 forControlEvents:UIControlEventTouchUpInside]; // you can ADD the action to the button as well like

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(50, 0, 100, 44)];
[label setAttributedText:[[NSMutableAttributedString alloc]
                          initWithString:NSLocalizedString(@"My Closet", nil)
                          attributes:@{
                                       NSForegroundColorAttributeName:[UIColor whiteColor],
                                       NSFontAttributeName: [UIFont fontWithName:@"Futura-Medium" size:13]
                                       }]];

UIView *buttonView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 100, 44)];
[buttonView addSubview:button];
[buttonView addSubview:label];

UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithCustomView:buttonView];
[leftButtons addObject:backButton];
[self.navigationItem setLeftBarButtonItems:leftButtons animated:NO];

navi1.png


2번 내용 코드
NSMutableArray *leftButtons = [[NSMutableArray alloc] init];
UIBarButtonItem *backButton = [[UIBarButtonItem alloc]
                               initWithImage:[UIImage imageNamed:@"title_btn_back_w_nor"]
                               style:UIBarButtonItemStylePlain
                               target:self
                               action:@selector(backButtonTapped)];
[leftButtons addObject:backButton];
[self.navigationItem setLeftBarButtonItems:leftButtons animated:NO];

UILabel* titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 44, 320, 44)];
titleLabel.textAlignment = NSTextAlignmentLeft;
NSMutableAttributedString *attributedText = [[NSMutableAttributedString alloc]
                                             initWithString:NSLocalizedString(@"My Closet", nil)
                                             attributes:@{
                                                          NSForegroundColorAttributeName:[UIColor whiteColor],
                                                          NSFontAttributeName: [UIFont fontWithName:@"Futura-Medium" size:13]
                                                          }];
titleLabel.attributedText = attributedText;
self.navigationItem.titleView = titleLabel;

navi2.png


[참고] http://stackoverflow.com/questions/30007281/uinavigationbar-horizontal-position
?

List of Articles
No. Category Subject Author Date Views
1077 System/OS [linux] ipchains 사용예(패킷 필터링) hooni 2003.04.23 14171
1076 System/OS [linux] ipfwadm를 이용한 패킷필터링(구버전) hooni 2003.04.23 13015
1075 System/OS [windows] 98/ME 속도 빠르게 튜닝(부팅,메모리,레지스터) hooni 2003.04.23 50439
1074 System/OS [windows] 도스 사용 팁 hooni 2003.04.23 17806
1073 System/OS [windows] 여러가지 활용 팁 hooni 2003.04.23 19969
1072 System/OS [windows] 배치(bat)파일 제작 방법 hooni 2003.04.23 17002
1071 System/OS [linux] 패킷 스니퍼링 hooni 2003.04.23 16315
1070 System/OS [linux] 패킷의 소스 주소 바꾸기 hooni 2003.04.23 18784
1069 System/OS [linux] iptables 명령어 매뉴얼(options) hooni 2003.04.23 11333
1068 System/OS [linux] 간단한 NAT 설정 script hooni 2003.04.23 12595
1067 System/OS [linux] 랜카드 2개 설정 & iptables 로 사설 ip.. hooni 2003.04.23 14730
1066 System/OS [linux] apache, php, jsp 환경설정하기.. hooni 2003.04.23 15230
1065 System/OS [linux] Oracle8.1.6, Mysql+PHP+Zend Optimizer+APACHE+Tomcat(jsp,servlet)+IMAP+gd hooni 2003.04.23 32450
1064 System/OS [linux] 특수문자 환경 설정(stty) hooni 2003.04.23 15273
1063 System/OS [linux] 메타(기호)문자의 의미와 사용 hooni 2003.04.23 16381
1062 System/OS [linux] 프로세스 상태확인(ps) hooni 2003.04.23 12701
Board Pagination Prev 1 5 6 7 8 9 ... 74 Next
/ 74