我有一个 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/