Views 2091 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
965 PPT [ppt] iOS 플라랩#02(2015.03.19) 발표 자료 file hooni 2015.04.24 900
964 Etc WM미통기 - 10. 조건부확률 hooni 2015.04.20 707
963 Etc 수리통계학 : 표본공간과 사상-1 hooni 2015.04.20 902
962 Etc EBS [수학영역] 미적분과 통계 기본 - 정규분포의 의미와 특징은? hooni 2015.04.20 1003
961 Develop [js] e.stopPropagation() VS e.preventDefault () file hooni 2015.04.14 810
960 Develop [js] 모바일 스크롤 방지(해제) hooni 2015.04.14 1590
959 Develop [js] 스크롤 이벤트 막기 hooni 2015.04.14 1009
958 Develop [ios] 앱에서 설정화면 호출하기 hooni 2015.04.07 747
957 Develop [ios] GMT Date와 Local Date 변환하기 hooni 2015.04.07 831
956 Etc 아이폰의 터치스크린 정확도 file hooni 2015.04.01 1419
955 Develop [ios] 아이폰 앱 이름 및 버전 정보 hooni 2015.03.24 855
954 Develop [ios] 카메라 사용 권한 확인해서 분기하는 방법 hooni 2015.02.26 1873
953 PPT [ppt] iOS 플라랩#01(2015.02.26) 발표 자료 file hooni 2015.02.25 733
952 Develop [ios] Touch ID 적용 샘플 코드 (예제) file hooni 2015.02.23 670
951 Develop [펌] 게임 엔진 만든거 공개합니다. hooni 2015.02.21 2357
950 Develop [ios] StoryBoard(xib) 없이 프로젝트 만들기 file hooni 2015.02.12 1069
Board Pagination Prev 1 ... 12 13 14 15 16 ... 74 Next
/ 74