【问题标题】:UIButton - turning off or reduing "selection/hold down" tint colourUIButton - 关闭或减少“选择/按住”色调颜色
【发布时间】:2013-09-28 06:08:54
【问题描述】:

我想要一种方法来减少在 iOS 7 和 6 上按住 UIButton 时出现的暗度变化(或作为最后的手段关闭)。由于选中时按钮上的图像,它看起来很糟糕

谢谢

迪伦

【问题讨论】:

    标签: objective-c uibutton tint


    【解决方案1】:

    您可以根据UIControlState 设置不同的图像和/或背景图像。 以图片为例:

    [comment_notification setBackgroundImage:[UIImage imageNamed:@"1"] forState:UIControlStateNormal];//Normal state
    
    [comment_notification setBackgroundImage:[UIImage imageNamed:@"2"] forState:UIControlEventTouchUpInside];//pressed and released state
    
    [comment_notification setBackgroundImage:[UIImage imageNamed:@"3"] forState:UIControlEventTouchDown];//pressed state
    

    或者在背景颜色的情况下,添加目标:

    [loginButton addTarget:self action:@selector(performLogin) forControlEvents:UIControlEventTouchUpInside];
    [loginButton addTarget:self action:@selector(loginButtonPressed) forControlEvents:UIControlEventTouchDown];
    [loginButton addTarget:self action:@selector(releasedButton:) forControlEvents:UIControlEventTouchUpOutside];
    

    在目标方法中,比如buttonpressed:

    - (void) buttonpressed:(UIButton*)button{
    
        [button setBackgroundColor:[UIColor blueColor]];
    }
    

    各个州的等等

    【讨论】:

    • 我会检查一下,然后给你完整的答案。
    猜你喜欢
    • 2011-09-06
    • 2011-01-27
    • 2010-12-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-09-20
    • 2021-09-15
    相关资源
    最近更新 更多