Develop
2014.01.09 14:19

[ios] UIButton multi-line iOS7

Views 11435 Votes 0 Comment 0
?

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
예전에 멀티라인 버튼을 아래처럼 작성했던게..
button.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
button.titleLabel.textAlignment = UITextAlignmentCenter;
[button setTitle: @"Line1\nLine2" forState: UIControlStateNormal];

iOS6 에서 UILineBreakModeWordWrap, UITextAlignmentCenter 이게 deprecated 됨..
그래서.. 이렇게~
button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
button.titleLabel.textAlignment = NSTextAlignmentCenter;
[button setTitle: @"Line1\nLine2" forState: UIControlStateNormal];

Background, Text, Multi-Line 샘플..
_button = [UIButton buttonWithType:UIButtonTypeCustom];
_button.frame = CGRectMake(buttonWidth*1, 65, buttonWidth, 43);
_button.titleLabel.font = [UIFont systemFontOfSize:12];
_button.titleLabel.lineBreakMode = NSLineBreakByWordWrapping;
_button.titleLabel.textAlignment = NSTextAlignmentCenter;

[_button setTitle:@"라인1\n라인2" forState:UIControlStateNormal];

[_button setTitleColor:[UIColor
    colorWithRed:153/255.0
    green:153/255.0
    blue:153/255.0 alpha:1.0] forState:UIControlStateNormal];

[_button setTitleColor:[UIColor
    colorWithRed:81/255.0
    green:19/255.0
    blue:137/255.0 alpha:1.0] forState:UIControlStateSelected];

[_button setBackgroundImage:
    [UIImage imageNamed:@"06_setting_category_tab_n"]
    forState:UIControlStateNormal];

[_button setBackgroundImage:
    [UIImage imageNamed:@"06_setting_category_tab_s"]
    forState:UIControlStateSelected];

[_button addTarget:self
    action:@selector(_buttonAction:)
    forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:_button];

?

List of Articles
No. Category Subject Author Date Views
69 System/OS 맥 OS X 에서 스크린 화면 캡쳐 단축키 (Mac Print Screen) hooni 2015.07.21 1900
68 System/OS 맥북에서 MAC/윈도우 멀티부팅시 시간 설정 file hooni 2013.04.23 29759
67 System/OS 맥에서 파일공유 (윈도우,맥) file hooni 2013.04.25 37301
66 System/OS 맥에서 포트 확인하고 닫기 (mac) hooni 2022.03.22 892
65 Etc 모바일 프로그래머가 갖추어야 할 필수 역량 file hooni 2017.02.16 1293
64 Develop 모터에 대한 pid 제어.. ㅎㅎ file hooni 2013.04.23 18878
63 System/OS 무료로 HTTPS 적용하기 (Let's Encrypt) file hooni 2017.10.28 1401
62 System/OS 무료로 HTTPS 적용하기 (Lets' Encrypt) file hooni 2017.02.16 2174
61 System/OS 무선 인증 서버.. 김도.. ㅋㅋ file hooni 2013.04.23 17595
60 Develop 밸런싱 로봇.. 최종.. (관련 논문도 첨부) ㅋㅋ file hooni 2013.04.23 22820
59 Etc 베지어 곡선 (Bezier curve) file hooni 2013.08.18 221126
58 Develop 베지어 곡선(Bézier curve) 알고리즘(spline 곡선) 3 file hooni 2013.04.23 33259
57 Develop 사이버보안실무 발표자료 (2017.06.08) file hooni 2017.06.05 1201
56 Etc 사이버보안실무 수업 메모 hooni 2017.03.30 807
55 Develop 사이버보안실무 수업 메모 secret hooni 2017.03.23 0
54 Etc 사이버보안실무 시험. secret hooni 2017.04.20 0
Board Pagination Prev 1 ... 68 69 70 71 72 74 Next
/ 74