首页 文章

在iPhone sdk中为uibutton添加自定义文本

提问于
浏览
0

我想使用具有自定义文本的uibutton,如屏幕截图 . 在屏幕截图中,我添加了2 uilabel到文本"Module 1"和"Fungi & Fungal Infections"但是橙色背景是uibutton但是当我按下它时它显示它只按橙色按钮而不是文本 . 我想要的是'll set these to label to uibutton text so that It' ll显示当按下按钮时文本应该具有与按钮 Headers
Fungi Image
相同的效果 . 这怎么可能在这方面引导我,这对我来说会很棒 . 提前致谢 .

2 回答

  • 0

    您需要选择UIButton类型自定义并取消选中'Highlight adjusts image'您可以参考此图片它会对您有所帮助 . :)
    Restrict UIButton Highlight state

  • 2

    很简单,只需创建您想要的属性文本标签,并将其作为子视图添加到uiButton,就像这样 . 按钮在故事板中设置为自定义类型 .

    UILabel * label = [UILabel new];
    label.backgroundColor = [UIColor redColor];
    label.text = @"Custom text";
    [label sizeToFit];
    label.frame = _button.bounds;
    [_button addSubview:label];
    

相关问题