Hi Tôi có vấn đề đối với thiết lập nhiều dòng để nút của tôi mà là tuyên bố như thế:Nhiều dòng trong UIButton
button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode = UILineBreakModeWordWrap;
button.titleLabel.numberOfLines = 0;
button.titleLabel.shadowOffset = CGSizeMake (1.0, 0.0);
[button addTarget:self
action:@selector(myButtonClick)
forControlEvents:UIControlEventTouchDown];
button.frame = CGRectMake(0.0, 100.0, 317.0, 100.0);
[button setTitle:string forState:UIControlStateNormal];
button.titleLabel.font = [UIFont systemFontOfSize: 12];
button.titleLabel.text = @"ahoj";
NSMutableString *ObratString = [[NSMutableString alloc] initWithString:button.titleLabel.text];
[ObratString appendString:@"\n"];
[ObratString appendString:@"caw"];
[ObratString appendString:@"\n"];
[ObratString appendString:@"helllo"];
button.titleLabel.text = ObratString;
[ObratString release];
[self.view addSubview:button];
Nhưng cuối cùng tôi chỉ thấy dòng đầu tiên. Có cách nào để nó hoạt động không?
có thể trùng lặp của http://stackoverflow.com/questions/2265940/ breakline-in-uibutton-title – fresskoma
Xem một câu hỏi khác và một số câu trả lời về điều này - [tại đây] (http://stackoverflow.com/questions/604632/how-do-you-add-multi-line-text-to-a -uibutton) –