现在的位置: 首页 > 综合 > 正文

iOS 中UIButton的 settitle 和 titlelabel的使用情况

2019年03月31日 ⁄ 综合 ⁄ 共 805字 ⁄ 字号 评论关闭

在使用uibutton的时候,一般用

    UIButton*buttonrecommend = [[UIButton
alloc]initWithFrame:CGRectMake(0,
80, 100, 40)];

    buttonrecommend.tag =
13
;

    [buttonrecommend setTitle:@"热门商家" forState:UIControlStateNormal];

    [buttonrecommend setTitle:@"热门商家" forState:UIControlStateHighlighted];

    [buttonrecommend setTitleColor:[UIColor
blackColor] forState:UIControlStateNormal];

    //    [buttonrecommend setTitleColor:[UIColor blackColor] forState:UIControlStateHighlighted];

    [buttonrecommend setBackgroundImage:[UIImage
imageNamed:@"beijingtiao.png"]
forState:UIControlStateNormal];

    [buttonrecommend setBackgroundImage:[UIImage
imageNamed:@"beijingtiao.png"]
forState:UIControlStateHighlighted];

    [buttonrecommend addTarget:self
action:@selector(list:)
forControlEvents:UIControlEventTouchUpInside];


设置title的时候用

buttonrecommend.titlelabel = @"热门商家";用不了原因如下

抱歉!评论已关闭.