2
以下是代碼,我使用經由-addSublayer
到一個UIButton添加到層:如何使通過-addSublayer添加的UI元素:響應觸摸事件?
CAGradientLayer * tile = [[tile alloc] init];
UIButton *XImageButton = [[UIButton alloc]init];
XImageButton.frame= CGRectMake(kXButtonlocX, kXButtonlocY, kXButtonHeight,kXButtonWidth);
[XImageButton setTitle:@"xbutton" forState:UIControlStateNormal];
[XImageButton addTarget:nil action:@selector(XbuttonTouchEvent)
forControlEvents:UIControlEventTouchUpInside];
[tile addSublayer:XImageButton.layer];
的XImageButton
沒有響應觸摸事件。我該如何解決這個問題,以便它能夠做出迴應?