我的ios应用程序中有标签可以响应轻击手势。为了更改被点击的标签的属性,我通过执行此操作找出了哪个标签
CustomLabel * label = gestureRecognizer.view;
然后相应地更改我希望的属性。但是,上面的代码行会发出警告
incompatible pointer type initializing CustomLabel with an expression of type UIView
在没有收到警告的情况下,这样做的正确方法是什么?
-(void)handleGesture:(UIGestureRecognizer *)gestureRecognizer
{
if (gestureRecognizer.state != UIGestureRecognizerStateEnded)
return;
CustomLabel * label = gestureRecognizer.view;
label.textAlignment = NSTextAlignmentCenter;
label.backgroundColor = [UIColor greenColor];