关闭

ios设置按钮点击时的文字和图片(而非非背景)

859人阅读 评论(0) 收藏 举报
分类:
    UIImage *wifiPressBg = [UIImage imageNamed:@"wifi_prs"];
    self.wifiBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    [self.wifiBtn.titleLabel setFont:[UIFont systemFontOfSize:15]];
    [self.wifiBtn setTitle:@"Wi-Fi" forState:UIControlStateNormal];
    [self.wifiBtn setTitleColor:SPAColor(23,104, 228) forState:UIControlStateNormal];
   [self.wifiBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];
    [self.wifiBtn setImage:wifiPressBg forState:UIControlStateNormal];
    [self.wifiBtn setImage:wifiNormalBg forState:UIControlStateHighlighted];



注意:状态应该用UIControlStateHighlighted而 不是UIControlStateSelected,如果整成UIControlStateSelected怎么点击图片会不会变大笑

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场