Develop
2014.01.09 14:19

[ios] UIButton multi-line iOS7

조회 수 11463 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

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

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
예전에 멀티라인 버튼을 아래처럼 작성했던게..
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
번호 분류 제목 글쓴이 날짜 조회 수
1173 Develop '2014 모바일 개발 트렌드' 발표자료입니다. file hooni 2014.10.02 1137
1172 System/OS Apache CORS 설정 1 hooni 2020.09.04 2890
1171 Develop Aspect Oriented Programming in Objective-C hooni 2015.05.18 945
1170 System/OS asx미디어 정보 기록.. hooni 2003.04.23 20605
1169 System/OS CentOS 6.5 USB 설치 6 file hooni 2013.12.18 37800
1168 System/OS CentOS 에서 Cacti 설치하기 hooni 2015.01.02 1935
1167 System/OS Configure Postfix to Use Gmail SMTP on Ubuntu 18.04 file hooni 2020.02.07 1495
1166 Develop DDay Memo 1.9.4 소스코드 secret hooni 2015.10.03 0
1165 Etc EBS [수학영역] 미적분과 통계 기본 - 정규분포의 의미와 특징은? hooni 2015.04.20 1100
1164 System/OS Enable Safari Hidden Debug Menu in Mac OS X file hooni 2017.02.07 1728
1163 System/OS Enable the Develop Menu in Safari file hooni 2017.02.07 1334
1162 Develop GCM 사용하기 2 (단말에 GCM 구현하기) file hooni 2013.07.06 23411
1161 Develop GCM 사용하기 3 (JSP로 GCM 푸시 서버 만들기) 4 file hooni 2013.07.06 25423
1160 Develop git 브런치 배우기 (링크) hooni 2013.07.09 20700
1159 Develop GPL, AGPL, MPL,.. 한눈에 보는 오픈소스SW 라이선스 file hooni 2014.10.14 1263
1158 Etc GSM에서 음성이 실리는 과정 요약.. hooni 2013.04.23 17586
Board Pagination Prev 1 2 3 4 5 ... 74 Next
/ 74