UIButton titleLabel frame size returning CGSize with zero width & height

前端 未结 6 549
执笔经年
执笔经年 2021-02-01 23:16

For iOS7, I used the UIButton titleLabel.frame.size.width property to determine the width of my button title under different localisations so I could p

6条回答
  •  Happy的楠姐
    2021-02-02 00:02

    Set the title text, then make a sizeToFit for the title label, and try to get the titleLabel.frame.size.width

    [myButton setTitle:@"My Title" forState:UIControlStateNormal];
    [myButton.titleLabel sizeToFit];
    

提交回复
热议问题