/ / Як я можу додати розрив рядка для тексту UIButton? [дублікат] - iphone, какао-дотик, uikit, uibutton

Як я можу додати розрив рядка для тексту UIButton? [дублікат] - iphone, cocoa-touch, uikit, uibutton

Я хочу знати, як мати багаторядковий ярлик на UIButton.

Відповіді:

5 за відповідь № 1

Використовуйте властивість UIButton 'sLabel, зокрема властивість titleLabel.numberOfLines:

titleLabel
A view that displays the value of the currentTitle property for a button. (read-only)

@property(nonatomic,readonly,retain) UILabel *titleLabel
Discussion
Although this property is read-only, its own properties are read/write. Use these
properties to configure the appearance of the button label. For example:

UIButton *button                  = [UIButton buttonWithType: UIButtonTypeRoundedRect];
button.titleLabel.font            = [UIFont systemFontOfSize: 12];
button.titleLabel.lineBreakMode   = UILineBreakModeTailTruncation;
button.titleLabel.shadowOffset    = CGSizeMake (1.0, 0.0);
The titleLabel property returns a value even if the button has not been displayed yet.
The value of the property is nil for system buttons.