how do i let text fit to UIButton?
Posted
by
iAsk
on Stack Overflow
See other posts from Stack Overflow
or by iAsk
Published on 2012-12-02T04:34:21Z
Indexed on
2012/12/02
5:04 UTC
Read the original article
Hit count: 167
problem:
Button size is enough, however when I change title, the title text cannot fit the button width. Any SDK function can solve this problem, or I need to manually code to solve it?
Please refer to following pictures.
design in the nib file.
initial show in simulator
when I change the title text
tried some ways before
_button.titleLabel.adjustsFontSizeToFitWidth = YES;
the way will change my font size. I cannot accept the way.[_button setTitleEdgeInsets:UIEdgeInsetsMake(10.0, 10.0, 0.0,0.0)];
the way change label's position only, not label size.[_button.titleLabel sizeToFit];
result is same with picture(3).[_button sizeToFit];
title moved to upper left corner, and the title still the same result.
Just confused, my button size is big enough, why title size is so small?
© Stack Overflow or respective owner