iphone - 如何通过点击更改 UILabel 的 alpha?

标签 iphone ios uilabel alpha

我有一个 iOS (4.0) 应用程序,我想通过点击屏幕上的任意位置来更改特定 UILabel 的 alpha。我没有以编程方式完成我的界面,我只是使用界面构建器将标签放置在屏幕上。

我如何使用点击手势来更改程序中特定 UILabel 的 alpha?

提前致谢!

最佳答案

在viewDidLoad中:

UITapGestureRecognizer *oneTap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(tapAction:)];
    [oneTap setNumberOfTapsRequired:1];
    [oneTap setNumberOfTouchesRequired:1];
    [self.view oneTap];

然后定义方法:

-(void)tapAction:(UIGestureRecognizer *)gesture 
    {
          [self.yourLabel setAlpha:0.5f]; // set the alpha to whatever you want, or animate the fade, whatever
    }

关于iphone - 如何通过点击更改 UILabel 的 alpha?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6697200/

相关文章:

ios - 从 pod 安装框架后,无法在 Swift 项目中导入类

swift - 从 NSMutableAttributedString 中删除项目符号点

ios - 从标签中删除缩进

iphone - Objective C 中 UITableView 标题中的 UILabel

ios - 如何修复 mapKit Ios 中使用的过多内存?

iphone - 在 iPhone 应用程序中将 .m4r/.mp3 转换为 .caf/.aiff

ios - 通过辅助方法呈现 View Controller

iphone - 如何在一段时间后触发委托(delegate)方法?

ios - 在 64 位 iOS 设备上更改唯一标识符

video - 是否可以在 iOS 中使用视频作为 GL 的纹理?