조회 수 2199 추천 수 0 댓글 0
Atachment
첨부 '3'
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
구글에 비슷한 질문을 했더니 역시나 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
?

  1. [iphone] 아이폰 어플 모음 ㅋㅋ

    Date2013.04.23 CategoryDevelop Byhooni Views13707
    Read More
  2. [unix] 로그파일 정리 쉘스크립트

    Date2014.02.19 CategoryDevelop Byhooni Views10886
    Read More
  3. [linux] 초간단 Postfix, Covecot, SSL/TLS (SMTP)

    Date2017.12.11 CategorySystem/OS Byhooni Views9528
    Read More
  4. [mysql] 쿼리 실행시 ERROR 1366 (HY000) : incorrect string value : for column

    Date2017.03.30 CategoryDatabase Byhooni Views8982
    Read More
  5. Mac OS 에 Jenkins 설치하기 (Homebrew)

    Date2017.03.15 CategoryDevelop Byhooni Views8409
    Read More
  6. [c] 프로세스 검사하기

    Date2013.04.23 CategoryDevelop Byhooni Views8051
    Read More
  7. [ios][swift] 초간단 카달로그 앱 (Catalog App)

    Date2016.06.27 CategoryDevelop Byhooni Views7458
    Read More
  8. [ios] UUID 생성 + Key Chain 연동

    Date2016.05.13 CategoryDevelop Byhooni Views4791
    Read More
  9. [android] dp, px 서로 변환

    Date2016.10.21 CategoryDevelop Byhooni Views3510
    Read More
  10. 무료로 HTTPS 적용하기 (Lets' Encrypt)

    Date2017.02.16 CategorySystem/OS Byhooni Views2395
    Read More
  11. XML, JSON, BSON, MSGPACK 장,단점 비교

    Date2017.01.11 CategoryDevelop Byhooni Views2385
    Read More
  12. 서버 확장을 위한 두 가지 방법

    Date2018.08.29 CategorySystem/OS Byhooni Views2276
    Read More
  13. [ios] 기본 네비게이션바의 타이틀, back버튼 위치와 속성 변경

    Date2016.05.16 CategoryDevelop Byhooni Views2199
    Read More
  14. [matlab] ZigZag-Scanning (2-D Array)

    Date2016.10.15 CategoryDevelop Byhooni Views2122
    Read More
  15. [ios] 웹뷰 history.back() ㅋㄷ

    Date2016.06.27 CategoryDevelop Byhooni Views2046
    Read More
  16. [ios] 동영상 플레이어 샘플 (for Remote Url)

    Date2017.02.07 CategoryDevelop Byhooni Views1769
    Read More
Board Pagination Prev 1 2 3 4 5 6 Next
/ 6