【发布时间】:2010-04-27 22:25:21
【问题描述】:
大家好,我这样创建这个按钮:
_myButton = [[UIButton buttonWithType:UIButtonTypeCustom] retain];
DLBadgeLayerDelegate *layerDelegate = [[DLBadgeLayerDelegate alloc] init];
_myButton.frame = CGRectMake(0.0 , 0.0, 100.0, 100.0);
[_myButton addTarget:self action:@selector(myButtonTapped:) forControlEvents:UIControlEventTouchUpInside];
_myButton.layer.backgroundColor = [[UIColor redColor] CGColor];
_myButton.center = CGPointMake(10.0, 10.0);
[self addSubview:_myButton];
[_myButton release];
该按钮出现在屏幕上,但如果我点击它,则没有任何反应。如果我只是创建一个圆角矩形按钮,而不是在其图层上没有自定义绘图,或者如果我只是将图层代码行留在外面,那么一切都很好。你有什么想法为什么我会出现这种行为,因为我想在按钮的图层中进行一些自定义绘图?
【问题讨论】:
标签: iphone uibutton calayer uicontrol