【问题标题】:Change UIImageView alpha state on tap点击更改 UIImageView alpha 状态
【发布时间】:2013-05-06 21:40:04
【问题描述】:

希望通过点击手势更改 UIimageview alpha,例如:

点击 - 将 alpha 更改为 0.5f
再次点击 - alpha 回到 1 状态

有可能吗?

【问题讨论】:

    标签: ios gesture alpha tap


    【解决方案1】:

    是的。

    将点击手势识别器附加到视图:

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(yourFunction:)];
    [imageView addGestureRecognizer:tap];
    

    然后在手势识别器的处理程序中:

    if (imageView.alpha > 0.5f){
        imageView.alpha = 0.5f;
    }
    else {
        imageView.alpha = 1.0;
    }
    

    【讨论】:

    • 我想知道,UITableViewCell中imageView的alpha值改变后是否需要调用- (CGRect)rectForRowAtIndexPath:(NSIndexPath *)indexPath
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-05-26
    • 1970-01-01
    • 2011-10-05
    • 2011-09-27
    • 2019-11-26
    • 1970-01-01
    相关资源
    最近更新 更多