zoukankan      html  css  js  c++  java
  • 让UIButton在按下时没有高亮效果

    How are you setting the images for the different UIControlStates on the button? Are you setting a background image for UIControlStateHighlighted as well as UIControlStateSelected?

    UIImage *someImage = [UIImage imageNamed:@"SomeResource.png"];
    [button setBackgroundImage:someImage forState:UIControlStateHighlighted];
    [button setBackgroundImage:someImage forState:UIControlStateSelected];

    If you're setting the selected state on the button touch down event rather than touch up inside, your button will actually be in a highlighted+selected state, so you'll want to set that too.

    [button setBackgroundImage:someImage forState:(UIControlStateHighlighted|UIControlStateSelected];

    Edit:

    To sum up my remarks in the comments and to address the code you posted...you need to set your background images for the full UIControl state that you're in. According to your code snippet, this control state would be disabled+selected+highlighted for the duration of the network operation. This means that you would need to do this:

    [button setBackgroundImage:someImage forState:(UIControlStateDisabled|UIControlStateHighlighted|UIControlStateSelected];

    If you remove the highlighted = YES, then you would need this:

    [button setBackgroundImage:someImage forState:(UIControlStateDisabled|UIControlStateSelected];

     http://stackoverflow.com/a/1785059

  • 相关阅读:
    链家大数据多维分析引擎实践
    html 读取变量
    django 分配字典给前台模板
    django将数组传递给前台模板
    fetachone和fetchall
    django捕获url中的值
    django 控制页面跳转
    MySQL的前缀索引及Oracle的类似实现
    django url捕获
    django 页面调用方法
  • 原文地址:https://www.cnblogs.com/ihojin/p/uicontrolstate.html
Copyright © 2011-2022 走看看