iPhone/iPad UIButton TitleLabel text not appearing

后端 未结 6 1548
北海茫月
北海茫月 2021-02-05 01:08

I created a grid of buttons. The following code creates the buttons and displays them, but there is no text on the button. Is there a setting I am missing? (Obj-C replies are fi

6条回答
  •  心在旅途
    2021-02-05 02:04

    UIButton *  selectCountryBtn =  [[UIButton alloc]initWithFrame:CGRectMake(0, 0, 100, 100)];  
    
    [selectCountryBtn setTitle:@"My Title" forState:UIControlStateNormal];
    

    Here, I have create sample programmatically button, and then set the title for its Normal Control state, You can use your own button object for set the title string, additionally you can also set title text for another control states by change UIControlStateNormal to another required states.

提交回复
热议问题