美文网首页
UIButton的属性enabled和userInteracti

UIButton的属性enabled和userInteracti

作者: 雪里的懒猪 | 来源:发表于2019-05-23 10:33 被阅读0次

    出现的场景:
    UIButton上设置背景图片,结果背景图片的色值会变淡,有透明度
    [_numberMark setBackgroundImage:[UIImage imageNamed:@"baifen-di"] forState:UIControlStateNormal];
    _numberMark. enabled = NO;
    原因:

    在官方文档中,enabled的描述中提到,当enabled的值被设置为NO时,有可能会重绘它本身;然而在userInteractionEnabled的描述中没有提到,但是值得注意的是,当执行动画时,视图默认是不能操作,可以通过配置UIViewAnimationOptionAllowUserInteraction来改变默认情况。

    whereas a disabled control ignores touch events and may draw itself differently.
    补充:两者都是在UIKit中声明,并不是UIButton独有的属性。

    所以在使用时可以使用userInteractionEnabled,而不是enabled

    相关文章

      网友评论

          本文标题:UIButton的属性enabled和userInteracti

          本文链接:https://www.haomeiwen.com/subject/hqfvzqtx.html